Calling Servlet through dispatcher loses Body payload data | Community
Skip to main content
Level 2
January 6, 2022

Calling Servlet through dispatcher loses Body payload data

  • January 6, 2022
  • 2 replies
  • 3604 views

I'm calling a servlet through POST method and passing data. When i tried to hit the author/publish instance directly, its working as expected.

Whereas when I'm hitting the servlet through dispatcher, the request payload data is coming as EMPTY.

 

Please share your inputs on the same

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

milind_bachani
Adobe Employee
Adobe Employee
January 6, 2022

Hi @vijaymanoharan 

Are you sure that the payload is empty and you are not getting a 404.
You get a 404 on dispatcher if servlet path is not allowed in the PUBLISH-FILTERS.

Can you please analyse the requests in network tab of dev-tools and post relevant screeenshots, so that we can guide further.

Thanks.

Level 2
January 7, 2022

Hi @milind_bachani , the payload is coming as empty whereas the payload is a JSON which i'm passing.

 

Note: Im trying to hit the servlet through external server. 

milind_bachani
Adobe Employee
Adobe Employee
January 7, 2022

Hi @vijaymanoharan 

Since you are hitting from external server, I suspect few things :

 

  • Are clientheaders set in dispatcher config under /clientheaders
  • Are you explicitly handling CORS ? - You can test that using CORS chrome extension and hit the servlet and check
  • Since the request is coming from external server, the body might be sent as plain-text instead of application/json but since your servlet was expecting JSON it comes up empty
  • Lastly, can you please hit <dispatcher_domain>/bin/notification POST using postman or any other api platform and check the behaviour.
    • If it works fine on postman with body you are sending, then possibly you need to check the external server configuration.
    • If NOT, then it has something to do with dispatcher config. By doing this activity, we can actually figure out the root-cause and the server responsible for bringing up such issue.

Thanks.

Shubham_borole
Community Advisor
Community Advisor
January 7, 2022

Hi @vijaymanoharan 

 

What does the servlet url look like?

Can you please check the dispatcher any file for '/filter' section 

For Eg: For /bin/test/myservlet
/0001 { /type "allow" /url "/bin/test/myservlet*" }

Also we can check the dispatcher debug and trace logs if any information regarding this is noted.

 

Thanks

 

Level 2
January 7, 2022

Hi @shubham_borole ,

 

The dispatcher filter file allows the particular path.

 

The dispatcher.log shows the trace as follow

 

[Fri Jan 07 08:25:11 2022] [D] [pid 6550] Found farm publishfarm for project.dev
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] checking [/bin/notification]
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] request URL has no extension: /bin/notification
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] cache-action for [/bin/notification]: NONE
[Fri Jan 07 08:25:11 2022] [T] [pid 6550] Filter rule entry /005 allowed 'POST /bin/notification HTTP/1.1'
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] Reusing connection: 10.44.1.98:4503
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] Connected to backend 0 (10.44.1.98:4503)
[Fri Jan 07 08:25:11 2022] [T] [pid 6550] request.uri = "/bin/notification"
[Fri Jan 07 08:25:11 2022] [T] [pid 6550] request.headers[Content-Type] = "application/json; charset=utf-8"
[Fri Jan 07 08:25:11 2022] [T] [pid 6550] request.headers[Via] = "1.1 project.dev (dispatcher)"
[Fri Jan 07 08:25:11 2022] [T] [pid 6550] request.headers[X-Forwarded-For] = "10.44.1.98"
[Fri Jan 07 08:25:11 2022] [T] [pid 6550] request.headers[Server-Agent] = "Communique-Dispatcher"
[Fri Jan 07 08:25:11 2022] [T] [pid 6550] request.headers[Host] = "10.44.1.98:4503"
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] Sending request body to remote server
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] Request body sent to remote server
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] No socket reuse: neither GET nor HEAD
[Fri Jan 07 08:25:11 2022] [I] [pid 6550] "POST /bin/notification" 500 none [publishfarm/0] 8ms
[Fri Jan 07 08:25:11 2022] [D] [pid 6550] Found farm publishfarm for project.dev

 

Note: I'm trying to hit the servlet from external server

Level 2
January 10, 2022

Hi @vijaymanoharan - The dispatcher log shows 500 as the response code, are you sure that you see 404(not found) as response code? In case of 500, you need to look into error.log of your publish instance. 

 

 


The error code 500 is coming because im trying to do operations with the payload data. due to which, 500 error code comes in @harish_malineni