views:

611

answers:

1

I am trying to access a Jackrabbit repository deployed on a JBoss application server via RMI.

I am getting the following exception when I try to connect to the factory using ClientRepositoryFactory.getRepository('rmi://xxx.xxx.xxx.xxx:1099/imageserver'). But if I create a web application that starts a new RMI registry on the server with a different port and register Jackrabbit in that new registry it works.

However, I need to get this working with the minimal tweaking to the default JBoss configuration. So can anybody shed some light on the causes for the problem. I have seen a lot of posts on the same topic elsewhere and we have tried all the plausible (and many un plausible) suggested solutions.

org.apache.jackrabbit.rmi.client.RemoteRuntimeException: java.rmi.ConnectIOException: non-JRMP server at remote endpoint
    org.apache.jackrabbit.rmi.client.SafeClientRepository.getDescriptor(SafeClientRepository.java:81)
    com.btmatthews.freelancer.webapp.servlet.TestServlet.doGet(TestServlet.java:39)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause

java.rmi.ConnectIOException: non-JRMP server at remote endpoint
    sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:230)
    sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
    sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
    sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    java.rmi.Naming.lookup(Naming.java:84)
    org.apache.jackrabbit.rmi.client.ClientRepositoryFactory$1.getRemoteRepository(ClientRepositoryFactory.java:95)
    org.apache.jackrabbit.rmi.client.SafeClientRepository.getDescriptor(SafeClientRepository.java:77)
    com.btmatthews.freelancer.webapp.servlet.TestServlet.doGet(TestServlet.java:39)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
+1  A: 

I think you might need to use a JNP client, which is different from IIOP and JRMP. That's the protocol JBoss exposes in 1099. This means that you might need to configure the initial context with something like:

Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial",
        "org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.provider.url", "jnp://localhost:1099");
env.put("java.naming.factory.url.pkgs",
        "org.jboss.naming:org.jnp.interfaces");

Context context = new InitialContext(env);

Service s = (Service) context.lookup("service");

s.sayHello();

Or may be you should start your own RMI server within a JBoss ear and publish in some other port.

Cheers.

mrrtnn