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

Resolver is already closed - sling exception

Avatar

Level 4

We are getting sling exception when multiple users load a page or when 2 actions are performed simultaneously .
The log says resolver is already closed , but the resolver is not closed in the code explicitly .
We have extended SCF Forum component and created a custom component which is being used in this page.
The exception occurs when we call super() i.e, AbstractPost.java and AbstractComment.java

 

Below is the exception in OOTB methods :

caused by: java.lang.IllegalStateException: Resource resolver is already closed.

        at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.checkClosed(ResourceResolverImpl.java:186) [org.apache.sling.resourceresolver:1.5.34]

        at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.adaptTo(ResourceResolverImpl.java:807) [org.apache.sling.resourceresolver:1.5.34]

com.adobe.cq.social.commons.comments.api.AbstractComment.getComponent(AbstractComment.java:1010) [com.adobe.cq.social.cq-social-commons:1.9.68]

        at com.adobe.cq.social.commons.comments.api.AbstractComment.setParentOrSourceComponent(AbstractComment.java:987) [com.adobe.cq.social.cq-social-commons:1.9.68]

        at com.adobe.cq.social.commons.comments.api.AbstractComment.getSourceComponent(AbstractComment.java:1020) [com.adobe.cq.social.cq-social-commons:1.9.68]

        at com.adobe.cq.social.forum.client.api.AbstractPost.isForumClosed(AbstractPost.java:161) [com.adobe.cq.social.cq-social-forum:1.7.9]

        at com.adobe.cq.social.forum.client.api.AbstractPost.isClosed(AbstractPost.java:145) [com.adobe.cq.social.cq-social-forum:1.7.9]

        at com.adobe.cq.social.forum.client.api.AbstractPost.canUserReply(AbstractPost.java:284) [com.adobe.cq.social.cq-social-forum:1.7.9]

        at com.adobe.cq.social.commons.comments.api.AbstractComment.<init>(AbstractComment.java:241) [com.adobe.cq.social.cq-social-commons:1.9.68]

        at com.adobe.cq.social.forum.client.api.AbstractPost.<init>(AbstractPost.java:83) [com.adobe.cq.social.cq-social-forum:1.7.9]

        at test.getTest(test.java:465) [com.test.project:1.0.0.SNAPSHOT]

        at test.setFields(test.java:165) [com.test.project:1.0.0.SNAPSHOT]

        at com.test.aem.core.test.models.component.scf.test.impl.test.<init>(Test.java:113) [com.test.project:1.0.0.SNAPSHOT]

        at com.test.aem.core.test.models.component.scf.test.impl.test.testMethod(Test.java:161) [com.test.project:1.0.0.SNAPSHOT]

       

 

Can you please let me know if any idea. 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

It looks like that you have closed teh resourceresolver some time earlier in the rendering process. Check your code for any resourceresolver.close() and validate that you call this only on a ResourceResolver which you have opened before.

 

See https://cqdump.wordpress.com/2018/11/12/resourceresolvers-and-sessions-you-open-it-you-close-it/ for best practices when to close a resource resolver.

 

regards,

Jörg

View solution in original post

3 Replies

Avatar

Correct answer by
Employee Advisor

It looks like that you have closed teh resourceresolver some time earlier in the rendering process. Check your code for any resourceresolver.close() and validate that you call this only on a ResourceResolver which you have opened before.

 

See https://cqdump.wordpress.com/2018/11/12/resourceresolvers-and-sessions-you-open-it-you-close-it/ for best practices when to close a resource resolver.

 

regards,

Jörg

Avatar

Level 4

Hi @Jörg_Hoh 

 

Thanks for the comments . 
We haven't closed it in the code . 
We are facing this issue in the OOTB Abstract Forum and Abstract Comment classes.
The issue is mainly occurring when multiple users try to reload a page at a time.

Avatar

Employee Advisor
in that case you have an unclean handling of resource resolvers. There is somewhere a component/service, which isn't stateless, but stores a resourceresolver in a global variable. You have to review your custom code for such an unclean handling.