4 Replies Latest reply on Apr 5, 2005 10:27 AM by arunchaks

    How to Acess JBOSS Naming Server (JNDI)/JBOSSMQ behind Firew

    arunchaks

      I would like to send & receive mesages to JBOSSMQ (jboss 3.2.5) over internet. The server is behind NAT & Firewall plus DNS. The JNDI lookup keeps on failing. I traced out the reason being RMI protocol issue. please refer http://forum.java.sun.com/thread.jspa?threadID=289869&messageID=1242288 Also tried with HTTP tunneling enabled for JNDI. Below is the stack trace and code snippet.


      Error Trace
      javax.naming.NamingException: Failed to retrieve Naming interface. Root exception is java.net.UnknownHostException: arunp
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153)
      at java.net.Socket.connect(Socket.java:434)
      at java.net.Socket.connect(Socket.java:384)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:386)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
      at sun.net.www.http.HttpClient.(HttpClient.java:303)
      at sun.net.www.http.HttpClient.(HttpClient.java:264)
      at sun.net.www.http.HttpClient.New(HttpClient.java:336)
      at sun.net.www.http.HttpClient.New(HttpClient.java:317)
      at sun.net.www.http.HttpClient.New(HttpClient.java:312)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:481)
      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:472)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:574)
      at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:1178)
      at java.net.URLConnection.getHeaderFieldInt(URLConnection.java:475)
      at java.net.URLConnection.getContentLength(URLConnection.java:370)
      at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:112)
      at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:65)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.(InitialContext.java:195)
      at JMSTest.doSend(JMSTest.java:28)
      at com.dialup.test.JMSTest.main(JMSTest.java:53)


      Test Case.

      import java.util.Properties;

      import javax.jms.Message;
      import javax.jms.Queue;
      import javax.jms.QueueConnection;
      import javax.jms.QueueConnectionFactory;
      import javax.jms.QueueReceiver;
      import javax.jms.QueueSender;
      import javax.jms.QueueSession;
      import javax.jms.Session;
      import javax.jms.TextMessage;
      import javax.naming.Context;
      import javax.naming.InitialContext;

      public class JMSTest
      {

      public void doSend()throws Exception

      {
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
      properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
      properties.put(Context.PROVIDER_URL, "http://hostname/invoker/JNDIFactory");
      InitialContext ctx = new InitialContext(properties);

      Queue queue = (Queue) ctx.lookup("queue/TestQueue");
      QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("UIL2ConnectionFactory");
      QueueConnection qc = qcf.createQueueConnection("arun","arun");

      try
      {
      QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      QueueSender sender = qs.createSender(queue);
      TextMessage message = qs.createTextMessage("testMessage @ " + System.currentTimeMillis());

      sender.send(message);
      }
      finally
      {
      qc.close();
      }
      }


      public static void main(String[] args) throws Exception
      {
      try
      {

      JMSTest sender = new JMSTest();
      sender.doSend();
      }
      catch(Exception e)
      {
      e.printStackTrace();
      }
      }
      }

        • 1. Re: How to Acess JBOSS Naming Server (JNDI)/JBOSSMQ behind F

          For the 10,004 time, naming questions do not belong in the jms forum.
          I'm going to create a specific user forum on naming/network configuration,
          although your host/firewall configuration is hardly a topic for the jboss forums anyway.

          • 2. Re: How to Acess JBOSS Naming Server (JNDI)/JBOSSMQ behind F
            arunchaks

            Thanks Adrian. Still UIL2 is unable to connect.
            I have changed the UIL2 descriptor for
            <!-- The bind address -->
            ${jboss.bind.address}
            to the IP (10.0.0.18). Still I am facing the problem. Hope this is also a general problem.

            Here is the trace.

            org.jboss.mq.SpyJMSException: Cannot authenticate user; - nested throwable: (java.net.ConnectException: Connection timed out: connect)
            at org.jboss.mq.Connection.authenticate(Connection.java:883)
            at org.jboss.mq.Connection.(Connection.java:238)
            at org.jboss.mq.SpyConnection.(SpyConnection.java:49)
            at org.jboss.mq.SpyConnectionFactory.createQueueConnection(SpyConnectionFactory.java:135)
            at com.dialup.test.JMSTest.doSend(JMSTest.java:49)
            at com.dialup.test.JMSTest.main(JMSTest.java:76)
            Caused by: java.net.ConnectException: Connection timed out: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
            at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
            at java.net.Socket.connect(Socket.java:434)
            at java.net.Socket.connect(Socket.java:384)
            at java.net.Socket.(Socket.java:291)
            at java.net.Socket.(Socket.java:147)
            at javax.net.DefaultSocketFactory.createSocket(DashoA6275)
            at org.jboss.mq.il.uil2.UILServerIL.createConnection(UILServerIL.java:579)
            at org.jboss.mq.il.uil2.UILServerIL.getSocketMgr(UILServerIL.java:500)
            at org.jboss.mq.il.uil2.UILServerIL.authenticate(UILServerIL.java:302)
            at org.jboss.mq.Connection.authenticate(Connection.java:876)

            • 3. Re: How to Acess JBOSS Naming Server (JNDI)/JBOSSMQ behind F
              antti

              If Naming is ok, try this in server:

              file: jms/uil2-service.xml

              <!-- use same address in uil2 service as your firewall natted is -->
              nikita.prolosoft.fi

              You coul also set properties in client, see
              http://www.jboss.org/wiki/Wiki.jsp?page=ConfigUIL2

              And you need jboss 3.2.6+ for this to work.

              • 4. Re: How to Acess JBOSS Naming Server (JNDI)/JBOSSMQ behind F
                arunchaks

                Hi Antti,

                I tried by specifying the same address as the firewall has natted(orange.stpc.net). Also tried with jboss3.2.7 by specifying the property (in UIL2 desciptor) clientAddress=orange.stpc.net. Still I get the same same error. Can u please help me out to get out of this.

                -arun