try (ResourceResolver writeAccessResourceResolver = userMapperService.getJCRWriterService();
ResourceResolver readAccessResourceResolver = userMapperService.getJCRReadService()) {
...
I am mocking userMapperService here , and returning aemContext.resourceResolver(), when userMapperService.getJCRWriterService() or userMapperService.getJCRReadService() is called.
My resourceresolver gets closed after the try block . But after the test case runs , it throws exception - " Resource Resolver is already closed " , nearAemContextImpl.tearDown method.
java.lang.IllegalStateException: Resource resolver is already closed.
at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.checkClosed(ResourceResolverImpl.java:186)
at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.adaptTo(ResourceResolverImpl.java:804)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.tearDown(SlingContextImpl.java:216)
at io.wcm.testing.mock.aem.context.AemContextImpl.tearDown(AemContextImpl.java:99)
at io.wcm.testing.mock.aem.junit5.AemContext.tearDownContext(AemContext.java:106)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.lambda$afterEach$2(AemContextExtension.java:115)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.applyAemContext(AemContextExtension.java:123)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.afterEach(AemContextExtension.java:110)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$11(TestMethodTestDescriptor.java:245)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$12(TestMethodTestDescriptor.java:256)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:256)
How to fix this issue?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @padmaja_seshadri ,
This can be caused by multi-threaded use of the same ResourceResolver or by closing a ResourceResolver or javax.jcr.Session that you didn't open in your own code.
Hope this kb article helps: https://helpx.adobe.com/in/experience-manager/kb/Random-Resource-resolver-is-already-closed-in-the-l...
Regards,
Santosh
Hi @padmaja_seshadri ,
This can be caused by multi-threaded use of the same ResourceResolver or by closing a ResourceResolver or javax.jcr.Session that you didn't open in your own code.
Hope this kb article helps: https://helpx.adobe.com/in/experience-manager/kb/Random-Resource-resolver-is-already-closed-in-the-l...
Regards,
Santosh
Views
Replies
Total Likes
Can you please add screenshot with highlighting the line of code where this exception is getting thrown when JUnit test runs, it will be helpful to understand/reproduce the issue which you are getting.
@padmaja_seshadri where u able to resolve this issue? Anychance did passing cloned resourceResolver help?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies