Programatically access AEM Publish Server from Author AEM6.5

Avatar

Avatar
Ignite 1
Level 1
tkantk
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
View profile

Avatar
Ignite 1
Level 1
tkantk
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
View profile
tkantk
Level 1

10-08-2020

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

Replies

Avatar

Avatar
Give Back 3
Level 4
SundeepKatepally
Level 4

Likes

76 likes

Total Posts

76 posts

Correct reply

21 solutions
Top badges earned
Give Back 3
Boost 10
Boost 25
Boost 50
Affirm 10
View profile

Avatar
Give Back 3
Level 4
SundeepKatepally
Level 4

Likes

76 likes

Total Posts

76 posts

Correct reply

21 solutions
Top badges earned
Give Back 3
Boost 10
Boost 25
Boost 50
Affirm 10
View profile
SundeepKatepally
Level 4

10-08-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