Details
-
Bug
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
Testing Sling Mock 2.2.12
-
None
Description
When you create a SlingContext using ResourceResolverType.JCR_OAK you get the following error if you do not have the required dependency:
java.lang.RuntimeException: Unable to initialize JCR_OAK resource resolver factory: Unable to instantiate resourcer resolver: org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapter. Make sure this maven dependency is included: org.apache.sling:org.apache.sling.testing.sling-mock-jackrabbit-oak
The message contains the groupId and artifactId of the dependency you are supposed to add to your project:
org.apache.sling:org.apache.sling.testing.sling-mock-jackrabbit-oak
The problem is that this dependency does not seem to exist. I was able to solve this issue by adding the following dependency:
<dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId> <version>2.0.2</version> </dependency>
This dependency does include the class org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapter which is apparently the class that is supposed to be loaded by all of this.
Therefore, I would propose to update the artifact coordinates in the error message.
I added a demo project that can be used to re-produce this issue:
- Extract the attached archive
- Run mvn clean test
- Error occurs
- Uncomment dependency in pom.xml
- Run mvn clean test
- Error is gone