2 Replies Latest reply on Apr 20, 2004 1:53 PM by Johannes Kuch

    EJB call through SSH tunnel (port forwarding), which ports t

    emu133 Newbie


      I have a jboss hosting ejb, and another application need to call the ejb hosted by jboss.

      Now the jboss hosting the ejb is running in one city, and I want to do the development of the other application in another city.

      I plan to use ssh2 port forwarding to connect them together.

      This is the code:
      protected void init(String url) throws Exception {
      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL, url);
      System.out.println("new InitialContext(p) ..., url ="+url);
      Context ctx = new InitialContext(p);
      Object objref = ctx.lookup("JNDI_name_my_ejb");

      If running in the same box, the url ="xxx.xxx.xxx.xxx:1100";
      not I forward local 1100 to remote xxx.xxx.xxx.xxx:1100

      if I telnet localhost 1100,
      i got the following msg:
      ?≤↨°Tα☻xp&?φt§http://serverName:8084/q~q~uq~♥├?φsr org.jnp.server.NamingServer_Stu

      (where serverName is the name of xxx.xxx.xxx.xxx)

      if i set the url to,
      i can see
      2003-05-09 14:17:22 Opening forwarded connection to xxx.xxx.xxx.xxx:1100
      2003-05-09 14:17:23 Forwarded port closed

      but the program stop there, seems waiting for connection, and till timeout.
      Exception is:
      [java] new InitialContext(p) ..., url =
      [java] javax.naming.CommunicationException. Root exception is java.rmi.Con
      nectException: Connection refused to host: xxx.xxx.xxx.xxx; nested exception is:
      [java] java.net.ConnectException: Operation timed out: connect
      [java] java.net.ConnectException: Operation timed out: connect
      [java] at java.net.PlainSocketImpl.socketConnect(Native Method)
      [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
      [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.jav
      [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
      [java] at java.net.Socket.(Socket.java:273)
      [java] at java.net.Socket.(Socket.java:100)
      [java] at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(R
      [java] at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(R
      [java] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:
      [java] at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.
      [java] at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.jav
      [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:83)
      [java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:48
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:46
      [java] at javax.naming.InitialContext.lookup(InitialContext.java:350)

      I noticed :sun.rmi.transport.tcp.TCPChannel.newConnection

      I am also forward local 1099, 1100, 4444,8084 to xxx.xxx.xxx.xxx, same ports.

      i am wondering if i can create the tunnel by forwarding one or several ports to establish the ssh tunnel, to let my application to make ejb call to the jboss in another city.

      (for your reference, I tried to call EJB on a commercial App server by this way, it works, so I think this should also jboss)

      Thank you for your help in advance.