1 Reply Latest reply on Dec 21, 2007 10:39 AM by adrian.brock

    JNDI over HTTP problem

    shiva79

      Hi All,
      I am having trouble getting JNDI over HTTP to work.
      I have done some reading on this during the last week, but could not get it to work.
      I went over section 3.6 Remote Access to Services, Detached Invokers,4.4 JNDI over HTTP, 7 Messaging on JBoss and 8 Security on JBoss from the JBoss Server Configuration Guide.
      JBoss forums:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=49763&postdays=0&postorder=asc&start=0
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=61717
      JBoss wiki:
      http://www.jboss.org/wiki/Wiki.jsp?page=ConfigHTTPIL
      http://wiki.jboss.org/wiki/Wiki.jsp?page=JMSOverHTTPS

      Here is my problem:
      I have a QueueSender posting messages to a queue "RDQueue" on my server running on my machine. I have a client on a different machine which has a QueueReceiver listening to messages posted on "RDQueue".
      I am trying to use JNDI over HTTP to allow the client to access this queue, but it doesn't work. The lookup for the ConnectionFactory fails.

      Below is my server configuration and the client code.

      On the server:
      In C:\jboss-4.0.3\server\default\deploy\http-invoker.sar\META-INF\jboss-service.xml

      <!-- Expose the Naming service interface via HTTP -->
       <mbean code="org.jboss.invocation.http.server.HttpProxyFactory"
       name="jboss:service=invoker,type=http,target=Naming">
       <!-- The Naming service we are proxying -->
       <attribute name="InvokerName">jboss:service=Naming</attribute>
       <!-- Compose the invoker URL from the cluster node address -->
       <attribute name="InvokerURLPrefix">http://</attribute>
       <attribute name="InvokerURLSuffix">:8080/invoker/JNDIFactory</attribute>
       <attribute name="UseHostName">false</attribute>
       <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
       <attribute name="JndiName"></attribute> <attribute name="ClientInterceptors">
       <interceptors>
       <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
       <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
       <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
       <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
       </interceptors>
       </attribute>
       </mbean>

      In C:\jboss-4.0.3\server\default\jms\jbossmq-httpil.sar\META-INF\jboss-service.xml
      <server>
       <mbean code="org.jboss.mq.il.http.HTTPServerILService"
       name="jboss.mq:service=InvocationLayer,type=HTTP">
       <depends optional-attribute-name="Invoker">jboss.mq:service=Invoker</depends>
       <depends>jboss.web:service=WebServer</depends>
       <attribute name="ConnectionFactoryJNDIRef">HTTPConnectionFactory</attribute>
       <attribute name="XAConnectionFactoryJNDIRef">HTTPXAConnectionFactory</attribute>
       <attribute name="PingPeriod">0</attribute>
       <attribute name="TimeOut">60</attribute>
       <attribute name="RestInterval">0</attribute>
       <attribute name="RestInterval">2</attribute>
       <attribute name="URLPrefix">http://</attribute>
       <attribute name="URLPort">8080</attribute>
       <attribute name="UseHostName">false</attribute>
       </mbean>
      </server>


      Client code:
      Properties prop = new Properties();
       prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
       prop.setProperty(Context.PROVIDER_URL, "http://xx.xxx.xxx.xxx:8080/invoker/JNDIFactory");
       prop.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
       jndiContext = new InitialContext(prop);
      
       System.out.println("Trying to get the queueConnectionFactory. ");
       ConnectionFactory connFactory = (ConnectionFactory)jndiContext.lookup("java:comp/env/jms/ConnectionFactory");
       System.out.println("Got the queueConnectionFactory. ");


      This is the error that I see when I try to run the client:
      [java] Trying to get the queueConnectionFactory.
       javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Failed to retrieve stub from server xx.xxx.xxx.27:1900 [Root exception is java.io.EOFException] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
       [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1399)
       [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
       [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       [java] at javax.naming.InitialContext.lookup(Unknown Source)
       [java] at org.jboss.naming.client.java.javaURLContextFactory$EncContextProxy.invoke(javaURLContextFactory.java:114)
       [java] at $Proxy0.lookup(Unknown Source)
       [java] at javax.naming.InitialContext.lookup(Unknown Source)
      ...

      I have also tried using jboss-client.jar / jbossall-client.jar in the classpath on both server and client. Still it doesnt work.

      Any help is deeply appreciated !

      Thanks
      Shiva.


        • 1. Re: JNDI over HTTP problem

          Try the jndi faq. e.g. java: namespace is not accesible remotely.

          The correct code is either:

          If you have defined it in your enc (again see JNDI FAQ for resource-refs)

          InitialContext jndiContext = new IntiialContext();
          ConnectionFactory connFactory = (ConnectionFactory)jndiContext.lookup("java:comp/env/jms/ConnectionFactory");
          


          or
          ConnectionFactory connFactory = (ConnectionFactory)jndiContext.lookup("HTTPConnectionFactory");