0 Replies Latest reply on Aug 30, 2005 3:42 PM by Dave Belfer-Shevett

    RMI + JNDI access to JBoss-hosted EJB's over ssh tunnels or

    Dave Belfer-Shevett Newbie

      I've been banging my head against this one for a couple days now, hope folks can help me out.

      I have an application I'm developing for a client. We've been developing it on localized machines for a while now, using all intra-net based services (jboss et al are all on the local machine). The app consists of a series of sessionbeans sitting in a deployed app in JBoss, accessed from a desktop Swing app via RMI.

      Locally, everything works fine. The jndi lookups work, I can get to the appserver without any problems. While in the end, the app will be installed in an intranet environment, I'd like my client to be able to run the Swing client remotely to test things out. I've deployed the Swing client app as a JNLP-enabled JAR file, and the users can download and run it, but I do not want to open up sockets through the firewall to the appserver (which is on a machine at a colo facility).

      What I'd like to do is either use direct socket-forwards in SSH, or use the SOCKS function (-D) to allow the remote Swing client access to the JNDI server and beans on the jboss server.

      I haven't found a real way to do this yet. My jndi.properties file states:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://127.0.0.1:1099


      So it would make sense that I could just use an ssh port forwarder to access the JNDI server:
      ssh -L1099:127.0.0.1:1099 my.remote.host


      Alas, that doesn't seem to work. When I run this, I get an exception on the InitialContext.lookup() call:
      [java] *** Exception thrown in com.arete.JQuo.AppsBrowse.connectUp() ...
       [java] *** javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
       [java] java.net.ConnectException: Connection refused]
       [java] javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
       [java] java.net.ConnectException: Connection refused]
       [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:707)


      Perversely, I still see a socket connect in ssh, so -something- is happening, why am I getting a Connection refused error?

      My ultimate goal is to use either a SOCKS remote proxy to get across the firewall to the JBoss server, or set up fixed sockets. I'll be happy with EITHER answer, this is not for production / final release, it's just so the client can see the work I'm doing.

      The code being used to connect is:
      System.out.println("Getting initial context...");
      Context c = new InitialContext();
      System.out.println("Looking up appmanager...");
      Object o = c.lookup ("AppManager");
      System.out.println("Back from lookup()...");


      I never see the last message - the exception is thrown on c.lookup().

      Help please?