Can not access a servlet via Ajax from dispatcher (404 - not found) | Community
Skip to main content
Level 2
September 25, 2022
Solved

Can not access a servlet via Ajax from dispatcher (404 - not found)

  • September 25, 2022
  • 3 replies
  • 3348 views

Hi everyone, I'm facing an issue when accessing a servlet (POST) via ajax from dispatcher.

Everything works well in my local and author mode.I've removed POST method in "com.adobe.granite.csrf.impl.CSRFFilter.cfg" as well as allowed the path in filters.any.

Here's my config: 

Remove for privacy

Do you guys have any idea for this issue? Please correct me if i'm wrong in any step.

Thanks.

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

Hi everyone, My issue has been resolved, The code is correct at all. I just forgot to uncheck ignore web tier configuration on a pipeline configuration. So the dispatcher wasn't deployed

 
 
 
 

 

3 replies

Level 2
September 25, 2022

As you have already confirmed it works fine in local publisher (it means you have enabled post method in servlet class and felix config also). I believe your servlet path is /bin/pdf/view and in filters.any it is allowing only GET method in your screenshot. Just allow post method for the same path.

Level 2
September 26, 2022

Thanks, @shashi_c .You probably misunderstood something. I registered the sling servlet that I mentioned above as resourceType with selector = 'dataForm' and extension = 'json'. the path bin/pdf/view is another servlet.

Mohit_KBansal
Adobe Employee
Adobe Employee
September 26, 2022

Test the following:

1. Test your servlet on publisher directly, you can use postman for it.

If the servlet is working fine on the publisher, then

2. Check dispatcher logs for any error for your servlet path

3. Also, you can try updating your rule 0107 by adding /method "POST"

 

Level 2
September 26, 2022

Hi @mohit_kbansal .

I tested the servlet on postman and it returned the same issue as dispatcher. (404 not found)

 

Mohit_KBansal
Adobe Employee
Adobe Employee
September 26, 2022

Now it makes sense. Please check this discussion [1], I hope you will find some direction.

 

[1] https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/servlet-not-working-on-publish-instance/m-p/181364

luongpham1994AuthorAccepted solution
Level 2
September 27, 2022

Hi everyone, My issue has been resolved, The code is correct at all. I just forgot to uncheck ignore web tier configuration on a pipeline configuration. So the dispatcher wasn't deployed