The Problem
I was trying to access the JCR via the following code.try {
repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
} catch (RepositoryException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
CSVImageImporter csvImageImporter=new CSVImageImporter();
try {
Credentials cd = new SimpleCredentials("admin", "admin".toCharArray());
session=repository.login(cd);
}
This resulted in the following exception:
javax.jcr.RepositoryException: Unable to access a repository with the following settings:
org.apache.jackrabbit.repository.uri: http://localhost:4502/crx/server
The following RepositoryFactory classes were consulted:
org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
Perhaps the repository you are trying to access is not available at the moment.
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:204)
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:244)
at au.com.someone.dam.csvimporter.ImportImageCSVTest.importCSVTest(ImportImageCSVTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
The Solution
Although I had added :
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
<version>2.2.0</version>
</dependency>
To my pom, I also needed to add:
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr2dav</artifactId>
<version>2.6.0</version>
</dependency>
legend....Missing jackrabbit-jcr2dav dependency solved the exact same issue for me!
ReplyDeleteThanks man that really worked in aem 6.5
ReplyDeleteI wasted nearly 24 hours for that!!!
I love you <3
ReplyDeleteThe problem is that org.apache.jackrabbit:jackrabbit-jcr-commons and org.apache.jackrabbit:jackrabbit-jcr2dav have the same file META-INF/services/javax.jcr.RepositoryFactory, which contains the Factory, the correct one is org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory.
ReplyDeleteBelow, this file was removed from jackrabbit-jcr-commons using shade plugin, to avoid conflict with jackrabbit-jcr2dav.
org.apache.maven.plugins
maven-shade-plugin
3.5.1
shade
org.apache.jackrabbit:jackrabbit-jcr-commons
META-INF/services/javax.jcr.RepositoryFactory
turing-aem
true
indexer
your.mainclass