Hi,
I'm trying to use the JCr-RMI concept for invoking the repository thru RMI.
The code which i used to register my repository with RMI is :
String configFile = "repository.xml";
String repHomeDir = "repository";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.jackrabbit.core.jndi" + ".provider.DummyInitialContextFactory");
env.put(Context.PROVIDER_URL, "localhost");
InitialContext ctx = new InitialContext(env);
RegistryHelper.registerRepository(ctx,
"repo",
configFile,
repHomeDir,
true);
Repository r = (Repository) ctx.lookup("repo");
String name="rmi://localhost:8084/repo";
RemoteAdapterFactory factory = new ServerAdapterFactory();
RemoteRepository remote = factory.getRemoteRepository(r);
//making RMI binding
Naming.bind(name, remote);
And the code which i used to retrive the repository thru RMI is:
// The RMI URL of the repository
String name = "rmi://localhost:8084/repo";
ClientRepositoryFactory factory = new ClientRepositoryFactory();
Repository repository = factory.getRepository(name);
String desc=repository.REP_NAME_DESC;
System.out.println("Description"+desc);
SimpleCredentials cred = new SimpleCredentials("userid",
"".toCharArray());
Session session = repository.login(cred, null);
Workspace ws = session.getWorkspace();
Node rn = session.getRootNode();
System.out.println("Name of the
RootNode"+rn.getPrimaryNodeType().getName());
When i run the code for retrieving the repository thru RMI..im getting the
following exception:
java.rmi.ConnectException: Connection refused to host: 172.20.54.84; nested
exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at java.rmi.Naming.bind(Naming.java:111)
at javaapplication2.Sample.main(Sample.java:80)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:180)
at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
... 6 more
Please help to resolve this.
Thanks,
--
View this message in context:
http://www.nabble.com/Getting-the-error-while-trying-to-access-the-repository-thru-jcr-RMI-concept-tp23404753p23404753.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.