Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

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

Avatar

Level 3

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.

1 Accepted Solution

Avatar

Correct answer by
Level 3

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

 
 
 
 

 

View solution in original post

10 Replies

Avatar

Level 2

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.

Avatar

Level 3

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.

Avatar

Employee Advisor

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"

 

Avatar

Level 3

Hi @Mohit_KBansal .

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

luongpham1994_0-1664172762161.png

 

Avatar

Level 3

I can access the servlet on publisher instance locally (4503) but not in server.

Avatar

Level 3

I just set a dispatcher up on local and i worked well. Not sure how it didn't work on server

Avatar

Community Advisor

Hi @luongpham1994 

In Filter.any file have you allowed the Post servlet that you have registered through resourceType. Can't see it in attached screen print.

Avatar

Level 3

Yes, I did. 

I tested it on the local dispatcher, When committed to the allowed path, The path is not found, and it worked again when uncommented. So I think the filters is working correctly

luongpham1994_0-1664191986704.png

 

Avatar

Correct answer by
Level 3

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