Hi All,
I am using Cq 4.2 and trying to access the CRX Repository using RMI and my test java application is as below:
package com;
import javax.jcr.Repository;
import javax.jcr.SimpleCredentials;
import javax.jcr.Session;
import javax.jcr.Workspace;
import javax.jcr.Node;
import javax.jcr.nodetype.NodeType;
import javax.jcr.NodeIterator;
import javax.jcr.PropertyIterator;
import javax.jcr.Property;
import javax.jcr.PropertyType;
import org.apache.jackrabbit.rmi.client.*;
public class access {
public static void main(String[] args) {
// TODO Auto-generated method stub
String repoUrl = "//localhost:1234/crxauthor";
Repository repository;
try {
ClientRepositoryFactory factory = new ClientRepositoryFactory();
System.setProperty("java.rmi.server.useCodebaseOnly", "true");
repository = factory.getRepository(repoUrl);
System.out.println(repository.getDescriptor(repository.REP_NAME_DESC));
} catch (Exception ex) {
// handle exception
ex.printStackTrace();
}
}
}
I have uncommented the rmi-port element in the web.xml located at
<cq-install>\server\runtime\0\_crxauthor\WEB-INF.
But i am unable to connect to the crx and recieve the following exception:
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.getRepository(ClientRepositoryFactory.java:86)
at com.access.main(access.java:29)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 8 more
I have included both the crx-rmi-1.3.1.jar and jcr-1.0.jar in the Eclipse application's classpath as well.
If anyone could kindly suggest where am i committing some error or leaving out any step.
with thanks,
Hemant
--- In jcr-crx@yahoogroups.com, "Jongwook Woo" <dalgual@...> wrote:
>
> Hi Felix:
>
> Thanks for the mail. However, it still does not work. I am using
> CQ4.0 and it seems you meant crxauthor for "crx".
>
> in web.xml, there are two rmi related lines:
> <init-param>
> <param-name>rmi-port</param-name>
> <param-value>0</param-value>
> <description>
> The RMI port for registering the repository in
> the RMI Registry.
> If equals 0, the default port is used. Ommit
> this parameter, to
> disable RMI server completely.
> </description>
> </init-param>
>
> <init-param>
> <param-name>rmi-uri</param-name>
> <param-value>//localhost:1099/jcrAuthor</param-value>
> </init-param>
>
> I uncommented them. And, I executed code and the following error:
>
> java.rmi.NotBoundException: jcrAuthor
> at sun.rmi.registry.RegistryImpl.lookup(Unknown Source)
>
> It seems that my url is wrong for RMI registry. This is the code:
> String repoUrl = "//localhost:1099/jcrAuthor";
> ClientRepositoryFactory factory = new ClientRepositoryFactory();
> try {
> repository = factory.getRepository(repoUrl);
>
> Thus, I modified the repoUrl as follows:
> repoUrl = "//localhost:1099/crxauthor";
>
> Then, I got followiong error:
> java.rmi.UnmarshalException: error unmarshalling return; nested
> exception is:
> java.net.MalformedURLException: no protocol: Files/Day/CQ-
> 4.0.1/server/runtime/0/_crxauthor/WEB-INF/classes
> at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
> at java.rmi.Naming.lookup(Unknown Source)
> at
> org.apache.jackrabbit.rmi.client.ClientRepositoryFactory.getRepositor
> y(ClientRepositoryFactory.java:86)
> at com.enetworks.eol.site.content.CRXHelper.main
> (CRXHelper.java:123)
> Caused by: java.net.MalformedURLException: no protocol: Files/Day/CQ-
> 4.0.1/server/runtime/0/_crxauthor/WEB-INF/classes
> at java.net.URL.<init>(Unknown Source)
>
>
> Is there something wrong in repoUrl?
>
>
> Regards,
>
> Jongwook
>
> --- In jcr-crx@yahoogroups.com, "fmeschbe" bark@ wrote:
> >
> > Hi,
> >
> > There is a 100% chance that no RMI registry is running at the
> > localhost:1099 ... There is all to it.
> >
> > But how come, nothing is there ? Easy: the default CRX installation
> > does not register the repository with RMI. You will have to do this
> > "by hand".
> >
> > 1. After first start locate the crx web app web.xml file in
> > runtime/0/_crx/WEB-INF folder of your CRX installation.
> > 2. Open the file with your preferred editor.
> > 3. Locate the rmi-port initial parameter
> > 4. This parameter is commented out by default
> > 5. Uncomment it
> > 6. Restart CRX
> >
> > Now you should be able to connect.
> >
> > Regards
> > Felix Meschberger
> >
> > --- In jcr-crx@yahoogroups.com, "Jongwook Woo" <dalgual@> wrote:
> > >
> > > Hi
> > >
> > > I wrote a code to call repository via RMI. But it returns the
> > > following error:
> > > 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.getRepositor
> > > y(ClientRepositoryFactory.java:86)
> > > at com.enetworks.eol.site.content.CRXHelper.main
> > > (CRXHelper.java:123)
> > >
> >
>