Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Unsure of why a custom servlet is not being registered

Avatar

Level 1

Hello all,

 

I'm building out a custom servlet using the code found here: https://github.com/arunpatidar02/aem63app-repo/blob/master/java/SimpleGetGroup.java

 

When I hit my localhost: localhost:4502/bin/get/groups, I receive this message: "Resource at '/bin/get/groups' not found: No resource found."

 

I noticed this line "LOG { 0 }: no servlet found" and I cannot find my servlet resolved under /system/console/configMgr or bundles or components. Testing under the Servlet Resolver Test with '/bin/get/groups' results in this as well: "The resource given by path '/bin/get/groups' does not exist. Therefore no resource type could be determined!"

 

I'm not sure what logs to check, error.log seems to be outputting the same info as well (I see "org.apache.sling.engine.imple.SlingRequestProcessImpl service: Resource /bin/get/groups not found."

 

Is there anything else I should check to see why my servlet's not resolving correctly? This is on an author instance as well. 

 

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @GRVYbb 

 

The issue I see is the methods:: 

SLING_SERVLET_METHODS + "=GET"

Your code doesn't have it and hence it's failing to bind.

 

Hope this helps!


Thanks,
Kiran Vedantam.

View solution in original post

5 Replies

Avatar

Employee

Hi @GRVYbb ,

 

Check if your bundles are active, and also if you can find them under the list of Components in the OSGi console.

 

Also, check if your servlet is resolving http://localhost:4502/system/console/servletresolver 

 

Ideally, you should register your servlets using resourceType, as it's recommended and registering through path has some caveats as mentioned here:

https://sling.apache.org/documentation/the-sling-engine/servlets.html#caveats-when-binding-servlets-... 

 

An example is part of the standard archetype, you can also find it here:-

https://github.com/adobe/aem-project-archetype/blob/develop/src/main/archetype/core/src/main/java/co... 

 

Hope this helps!

 

Regards,

Nitesh 

Avatar

Level 9

@GRVYbb you can check if your servlet path is allowed here-

ManuMathew1994_0-1674023936228.png

You can also 

to check if the servlet is resolved or not.

 

if its path based you need to use the: 

"sling.servlet.paths=" + "/bin/registeredbypathdemo"

and if its resource-based then use the: 

"sling.servlet.resourceTypes="+ "sample/components/structure/page"

This could be your resource type- associate your servlet with a resource type and selector, which prevents unauthorized access.

Avatar

Level 5

Hi @GRVYbb ,

I have used the same code and it seems working fine for me. Can you please check whether your servlet is in an active state or not? you can find your servlet in the OSGI container of the bundle details section as shown in the below image.

demo-project-practice.png

Thanks,

Ravi Joshi

Avatar

Community Advisor

Hi @GRVYbb 

 

Please check if the bundle is active.

Then check if all the services used in the Servlet is resolving or not and if the servlet is in an active state.

Check the error log as well for more information.

 

Thanks

Avatar

Correct answer by
Community Advisor

Hi @GRVYbb 

 

The issue I see is the methods:: 

SLING_SERVLET_METHODS + "=GET"

Your code doesn't have it and hence it's failing to bind.

 

Hope this helps!


Thanks,
Kiran Vedantam.