1 Reply Latest reply on May 15, 2004 7:54 AM by Steve Lewis

    Acces JNDI over Http

    stephen Newbie

      I try to access my remote Jboss JNDI server over HTTP with the following code. But failed.

      Could someone please shows me some code on how to do it correctly?

       Properties env = new Properties();
       env.setProperty(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
       env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
       "org.jboss.naming.HttpNamingContextFactory");
       env.setProperty(Context.PROVIDER_URL,"http://10.0.0.0:8080/invoker/JNDIFactory");
       Context ctx;
       try {
       ctx = new InitialContext(env);
       System.out.println("Created InitialContext, env="+env);
       Object data = ctx.lookup("jmx/rmi/RMIAdaptor");
       System.out.println("lookup(jmx/rmi/RMIAdaptor): "+data);
      
       } catch (NamingException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
      
      
      i get the following exception when i run the above code snippet
      
      Created InitialContext, env={java.naming.provider.url=http://219.93.192.206:8080/invoker
      /JNDIFactory,
      java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory,
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      
      javax.naming.CommunicationException: Operation failed [Root exception
      is java.net.ConnectException: Connection timed out: connect]
       at org.jboss.naming.interceptors.ExceptionInterceptor.invoke(ExceptionInterceptor.java:50)
       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(Unknown Source)
       at my.com.shinyang.eply.test.HttpInvokerTest.testMQ(HttpInvokerTest.java:233)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:410)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:294)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:182)
      Caused by: java.net.ConnectException: Connection timed out: connect
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(Unknown Source)
       at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at sun.net.NetworkClient.doConnect(Unknown Source)
       at sun.net.www.http.HttpClient.openServer(Unknown Source)
       at sun.net.www.http.HttpClient.openServer(Unknown Source)
       at sun.net.www.http.HttpClient.<init>(Unknown Source)
       at sun.net.www.http.HttpClient.<init>(Unknown Source)
       at sun.net.www.http.HttpClient.New(Unknown Source)
       at sun.net.www.http.HttpClient.New(Unknown Source)
       at sun.net.www.http.HttpClient.New(Unknown Source)
       at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
       at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
       at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
       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)
       ... 23 more
      
      
      


      Thanks

      Regards,
      Stephen