Unable to access AEM author using getRepository | Community
Skip to main content
MandaPavanKumar
Level 2
February 24, 2022
Solved

Unable to access AEM author using getRepository

  • February 24, 2022
  • 3 replies
  • 1547 views

Hi All,

    Any one could help me in resolving the following issue as I am not able to access the AEM repository using the following code :

Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
//Create a Session- put a valid creds who has the access of the repository
javax.jcr.Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()));

after executing this piece of code I am getting the following issue :

2022-02-24 11:12:30.001 ERROR [com.myaem65trainings.core.schedulers.DeleteNodeWithScheduler] Error Captured during :: 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:
Perhaps the repository you are trying to access is not available at the moment.

 

Can anyone please help me in this.

Thanks,

Pavan 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JeevanRaj

Hi @mandapavankumar 

 

If you are trying to access AEM JCR repo from a JAVA standalone application then you have to add the jackrabbit-standalone-2.4.0.jar file to your Java application’s class path. Here is an article to access JCR repo programatically. https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/access-jcr.html?lang=en

 

If you are trying to access the JCR repo from an AEM application then there few different ways you could that. One of the most used and recommended way is get the resourceResolver from a service user.

  1. Create a service user.
    https://experienceleague.adobe.com/docs/experience-manager-64/administering/security/security-service-users.html?lang=en
  2. Provide required permission to the service user.
  3. Get the resourceResolver using the service user.
    final Map<String, Object> param = Collections.singletonMap(ResourceResolverFactory.SUBSERVICE,
    <SERVICE_USER_NAME>);
    resourceResolver = resourceResolverFactory.getServiceResourceResolver(param);
    Here is an article that might help you.

    Thanks,

3 replies

JeevanRaj
Community Advisor
JeevanRajCommunity AdvisorAccepted solution
Community Advisor
February 24, 2022

Hi @mandapavankumar 

 

If you are trying to access AEM JCR repo from a JAVA standalone application then you have to add the jackrabbit-standalone-2.4.0.jar file to your Java application’s class path. Here is an article to access JCR repo programatically. https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/access-jcr.html?lang=en

 

If you are trying to access the JCR repo from an AEM application then there few different ways you could that. One of the most used and recommended way is get the resourceResolver from a service user.

  1. Create a service user.
    https://experienceleague.adobe.com/docs/experience-manager-64/administering/security/security-service-users.html?lang=en
  2. Provide required permission to the service user.
  3. Get the resourceResolver using the service user.
    final Map<String, Object> param = Collections.singletonMap(ResourceResolverFactory.SUBSERVICE,
    <SERVICE_USER_NAME>);
    resourceResolver = resourceResolverFactory.getServiceResourceResolver(param);
    Here is an article that might help you.

    Thanks,
DEBAL_DAS
New Member
February 24, 2022

If you are planning to write a stand alone Java class or stub to access AEM repository then you could follow above approach.

 

But if you are planning to access from OSGi service then use service user to access AEM repository.

 

As we could see I have added using Build Path[jackrabbit-standalone-2.4.0.jar(https://archive.apache.org/dist/jackrabbit/2.4.0/)] and able to access repository -

 

 

Able to persist node and property as shown below -

 

I have used AEM 6.5.9

Debal Das, Senior AEM Consultant