Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Connecting to AEM from JAVA

Avatar

Level 5

Am following up this article[0], where i can observe that if i use  

Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");

am able to see the below error.

And also has observed that if i use without any server crx detail like 

Repository repository = JcrUtils.getRepository();

then it works and shows the output.

[0] https://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-usi ng.html

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

kk krish wrote...

Still able to see same error, Attached is my simple java class and pom file which am using, and below is command for running project.

  1. mvn exec:java -Dexec.mainClass="com.org.krish.test.GetRepository"

 

 

 

Everything looks good except the dependency. Add the below dependency and it should work:

<dependency>
           <groupId>org.apache.jackrabbit</groupId>
           <artifactId>jackrabbit-jcr2dav</artifactId>
           <version>2.4.0</version>
     </dependency>

Thanks.

View solution in original post

7 Replies

Avatar

Level 5

According to this[0], any http(s) URI would use the org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory [1] and I'm not seeing that as one of the RepositoryFactory classes that were consulted. Not exactly an answer, but maybe that'll help you further troubleshoot the issue.

[0] https://jackrabbit.apache.org/api/2.8/org/apache/jackrabbit/commons/JcrUtils.html#getRepository(java...)
[1] https://jackrabbit.apache.org/api/2.2/org/apache/jackrabbit/jcr2dav/Jcr2davRepositoryFactory.html

Avatar

Level 8

I ran into the same issue.  I added the below code in the first line of my application and it worked correctly.

org.apache.log4j.BasicConfigurator.configure();

Avatar

Level 10

This article was written using Eclipse from a standalone app. ie - an external Java Swing app. 

Are you trying to follow this to build an AEM Bundle that is deployed in the OSGi service container? 

Avatar

Level 5

Still able to see same error, Attached is my simple java class and pom file which am using, and below is command for running project.

mvn exec:java -Dexec.mainClass="com.org.krish.test.GetRepository"

 

Avatar

Level 10

Try running code in a Java IDE and let us know what happens. 

Avatar

Correct answer by
Community Advisor

kk krish wrote...

Still able to see same error, Attached is my simple java class and pom file which am using, and below is command for running project.

  1. mvn exec:java -Dexec.mainClass="com.org.krish.test.GetRepository"

 

 

 

Everything looks good except the dependency. Add the below dependency and it should work:

<dependency>
           <groupId>org.apache.jackrabbit</groupId>
           <artifactId>jackrabbit-jcr2dav</artifactId>
           <version>2.4.0</version>
     </dependency>

Thanks.

Avatar

Level 5

Thanks it works, But still able to see some warnings in log, attached full command prompt trace.