Resolver is already closed - sling exception

Avatar

Avatar
Validate 1
Level 3
pallavis8124480
Level 3

Likes

13 likes

Total Posts

47 posts

Correct reply

3 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile

Avatar
Validate 1
Level 3
pallavis8124480
Level 3

Likes

13 likes

Total Posts

47 posts

Correct reply

3 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile
pallavis8124480
Level 3

11-03-2020

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. 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,166 posts

Correct reply

1,080 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,166 posts

Correct reply

1,080 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

13-03-2020

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

Answers (0)