Programatically access AEM Publish Server from Author AEM6.5 | Community
Skip to main content
Level 2
August 10, 2020

Programatically access AEM Publish Server from Author AEM6.5

  • August 10, 2020
  • 1 reply
  • 1592 views

We have a requirement in our application where we are building an utility which will only run on AEM author environment. This will search for users by his/her email ID on both author and publish servers. For this we have to connect to publish servers from author environment. I am trying to do it by using the following piece of code on author environment,

final String repoUrl = "http://localhost:4503/crx/server";
final javax.jcr.Repository repository = JcrUtils.getRepository(repoUrl);
final Session session = repository.login(new javax.jcr.SimpleCredentials("admin", "admin".toCharArray()), "crx.default"); 

But I am getting error while doing JcrUtils.getRepository(repoUrl) as below,

Unable to access a repository with the following settings: org.apache.jackrabbit.repository.uri: http://localhost:4503/crx/server The following RepositoryFactory classes were consulted: Perhaps the repository you are trying to access is not available at the moment..

Any help is highly appreciated

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

1 reply

SundeepKatepally
Community Advisor
Community Advisor
August 11, 2020

In order to get the user details , you shouldn't not create any session or respository object for publish. That would result in impacting end users.

 

Firstly , this requirement is little strange. But to solve the problem, simplest way that i would think is to hit a querybuilder.json api to fetch user data from /home/users. This requires hardly http connection in your java code. No other objects.

Example URL - 

http://localhost:4900/bin/querybuilder.json?type=rep:User&nodename=*username