How to register a server in the default RMI registry for JBoss and access it from a client running in another JVM?

I am trying to access the Jackrabbit repository deployed to JBoss via RMI.

I get 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 launches a new RMI registry on a server with a different port and registers Jackrabbit in this new registry, it works.

However, I need this minimal setup job to be configured by default for JBoss. So can someone shed light on the causes of the problem. I saw many posts on the same topic elsewhere, and we tried all the possible (and many unlikely) proposed 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)
+3
source share
1 answer

I think you might need to use a JNP client that is different from IIOP and JRMP. What the JBoss protocol provides in 1099. This means that you may need to configure the initial context with the following:

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 maybe you should start your own RMI server in JBoss's ear and publish it to another port.

Greetings.

+1

Source: https://habr.com/ru/post/1707840/


All Articles