2 Replies Latest reply on Feb 24, 2004 2:38 AM by jieshengz

    connection exception when JNDI over http

      I just want to do a simple JNDI connect from a client to server. My client is inside an interal Lan. Its is IP is like 10.0.0.35. My server has a public IP address and is a redhat 8.0 linux box.
      I can connect to server correctly since I could retrieve the
      http://xx.xx.xx.xx:8080/jmx-console page .
      However when I try to connect through JNDI/http, I have no luck.
      My code is very simple, it is like this

      Hashtable table = new Hashtable();
       table.put(
       "java.naming.factory.initial",
       "org.jboss.naming.HttpNamingContextFactory");
       table.put(
       "java.naming.provider.url",
       "http://xx.xx.xx.xx:8080/invoker/JNDIFactory");
       table.put(
       "java.naming.factory.url.pkgs",
       "org.jboss.naming:org.jnp.interfaces");
       InitialContext ctx = new InitialContext(table);
      
       TopicConnectionFactory conFactory =
       (TopicConnectionFactory) ctx.lookup("RMIConnectionFactory");
      


      I got this exception
      javax.naming.CommunicationException: Operation failed. Root exception is 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 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.getOutputStream(HttpURLConnection.java:528)
      at org.jboss.invocation.http.interfaces.Util.invoke(Util.java:101)
      at org.jboss.invocation.http.interfaces.HttpInvokerProxy.invoke(HttpInvokerProxy.java:102)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
      at org.jboss.naming.interceptors.ExceptionInterceptor.invoke(ExceptionInterceptor.java:42)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:55)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      at $Proxy0.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at JNDIOverHTTP.main(JNDIOverHTTP.java:56)

      Any help is really appreciated.

        • 1. Re: connection exception when JNDI over http

          More information for this post.
          For a regular naming lookup as below

          Hashtable table = new Hashtable();
          table.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
          table.put("java.naming.provider.url", "jnp://xx.xx.xx.xx:1099");
          table.put("java.naming.factory.url.pkgs",
          "org.jboss.naming:org.jnp.interfaces");
          ctx = new InitialContext(table);
          
          conFactory =(TopicConnectionFactory) ctx.lookup("RMIConnectionFactory");
          System.out.println(listNames(ctx));
          
          

          everything works fine. I checked the /etc/hosts file. The external IP is mapped to the hostname correctly.

          I had spent several days on this and have no luck.
          Please help out

          Thanks


          • 2. Re: connection exception when JNDI over http

            Ok the problem is solved.
            The key problem is that my hostname does not have a FQDN hostname. Therefore the http-invoker sends the hostname to my remote client which has no way to connect with it. All what I did is

            replace
            all <attri bute name="UseHostName">true
            in the $JBOSS/server/default/deploy/http-invoker.sar/META-INF/jboss-service.xml
            with
            <attri bute name="UseHostName">false