Hi,
AEM version: 6.0
Tried to make an rmi connection, from java application.
We followed the steps, as exactly as mentioned on the kb (https://helpx.adobe.com/experience-manager/kb/rmi-connection-crx-cq-561.html) and always we are getting the connection refused exception.
Apart from enabling RMI Connection listener, is we have to do anything at server level for enabling RMI?
In the code, we are referring to a parameter crx-application-name, where we have to configure the same?
Kindly advice us on this.
error.log (After enabling rmi listener):
*INFO* [CM Event Dispatcher (Fire ConfigurationEvent: pid=org.apache.sling.jcr.jackrabbit.server.RmiRegistrationSupport)] org.apache.sling.jcr.registration Using RMI Registry port 1199
*INFO* [JcrInstaller.1] org.apache.sling.installer.provider.jcr.impl.JcrInstaller Registering resource with OSGi installer: [InstallableResource, priority=200, id=/apps/system/config/org.apache.sling.jcr.jackrabbit.server.RmiRegistrationSupport.config]
Code Snippet:
public static void main (String[] args){
System.out.println("RMI to CRX Test Connection:");
ClientRepositoryFactory factory = new ClientRepositoryFactory();
Repository repository;
String crxApplicationName = "virtual-crx";
String repoUrl = "//localhost:1199/"+crxApplicationName;
String workspace = "crx.default";
String username = "admin";
char [] password = "admin".toCharArray();
try {
repository = factory.getRepository(repoUrl);
Session s = repository.login(new SimpleCredentials(username,password), workspace);
System.out.println("Workspace: " + s.getWorkspace().getName());
System.out.println("userId: "+s.getUserID());
} catch (Exception e) {
e.printStackTrace();
}
}
Exception:
RMI to CRX Test Connection:
Exception in thread "main" org.apache.jackrabbit.rmi.client.RemoteRuntimeException: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
at org.apache.jackrabbit.rmi.client.SafeClientRepository.getRemoteRepository(SafeClientRepository.java:85)
at org.apache.jackrabbit.rmi.client.SafeClientRepository.<init>(SafeClientRepository.java:56)
at org.apache.jackrabbit.rmi.client.ClientRepositoryFactory$1.<init>(ClientRepositoryFactory.java:90)
at org.apache.jackrabbit.rmi.client.ClientRepositoryFactory.getRepository(ClientRepositoryFactory.java:90)
at com.wbg.connectrepo.connectRepo.main(connectRepo.java:39)
Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at org.apache.jackrabbit.rmi.client.ClientRepositoryFactory$1.getRemoteRepository(ClientRepositoryFactory.java:95)
at org.apache.jackrabbit.rmi.client.SafeClientRepository.getRemoteRepository(SafeClientRepository.java:83)
... 4 more
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
We also tried to make an rmi connection as mentioned on (http://dev.day.com/docs/en/crx/current/developing/accessing_the_crx.html#Accessing a Repository via RMI), in that case also we are getting the same exception
Code Snippet:
public static void main(String[] args) throws Exception{
System.out.println("Test Rmi Connection.");
Repository repository = JcrUtils.getRepository("rmi://localhost:1199/crx");
SimpleCredentials creds = new SimpleCredentials("admin", "admin".toCharArray());
Session session = null;
session = repository.login(creds, "crx.default");
}
Exception:
Exception in thread "main" javax.jcr.RepositoryException: Unable to access a repository with the following settings:
org.apache.jackrabbit.repository.uri: rmi://localhost:1199/crx
The following RepositoryFactory classes were consulted:
org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory: declined
org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory: declined
org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory: failed
because of RemoteRuntimeException: java.rmi.RemoteException: Failed to look up the RMI resource //localhost:1199/crx; nested exception is:
java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
because of RemoteException: Failed to look up the RMI resource //localhost:1199/crx; nested exception is:
java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
because of ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
because of ConnectException: Connection refused: connect
Perhaps the repository you are trying to access is not available at the moment.
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:223)
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:263)
at com.wbg.connectrepo.connectRepo.main(connectRepo.java:21)
Thank,
Karthi