4 Replies Latest reply on Mar 19, 2005 2:11 PM by George Berish

    Local 3.6.2 Server InitialContext OK -- Remote doesn't???

    George Berish Novice

      I am trying to change a simple java JMS client.

      It now sends Messeges to, and receives them from a Queue on my local server.

      I want it to do the same from the same version server <3.6.2> that is running remotely on .org

      But JNDI lookup is defeating me. Can anyone point me to a solution?

      This code works fine:

      Properties p = new Properties();
       // get initial context
       p.put(Context.INITIAL_CONTEXT_FACTORY,
       "org.jnp.interfaces.NamingContextFactory");
       p.put(Context.PROVIDER_URL,
       "jnp://localhost:1099");
       p.put(Context.URL_PKG_PREFIXES,
       "org.jnp.interfaces");
      
       System.out.println ("Calling InitialContext");
       ctx = new InitialContext(p);
       System.out.println ("InitialContext Found" + ctx);
       }
       // lookup connection factory
       factory = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
       System.out.println ("Connection Factory instantiated");
      
       // lookup destination
       destination = (Queue)ctx.lookup("queue/goIn");
       System.out.println ("Destination instantiated");
       ...
      But this fails with the error as shown on the screen print below.
      Properties p = new Properties();
       p.put(Context.INITIAL_CONTEXT_FACTORY,
       "org.jboss.naming.NamingContextFactory");
       p.put(Context.PROVIDER_URL,
       "jnp://<myDomain>.org:1099");
       p.put(Context.URL_PKG_PREFIXES,
       "org.jboss.naming:org.jnp.interfaces");
      
       System.out.println ("Calling InitialContext");
       ctx = new InitialContext(p);
       System.out.println ("InitialContext Found");
      
       // lookup connection factory
       factory = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
       System.out.println ("Connection Factory instantiated");
      
       // lookup destination
       destination = (Queue)ctx.lookup("queue/goIn");
       System.out.println ("Destination instantiated");
       ...
      The print out of the failure is:
      Calling InitialContext
      InitialContext Found
      Naming Exception
      javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused
       to host: 127.0.0.1; nested exception is:
       java.net.ConnectException: Connection refused: connect]
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:649)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:509)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at MessageTest.setUp1(MessageTest.java:78)
       at MessageTest.main(MessageTest.java:26)
      ...
      SetUp Done.
      Press any key to continue . . .[\code]
      
      
      
      
      
      
      
      
      
      


        • 1. Re: Local 3.6.2 Server InitialContext OK -- Remote doesn't??
          Darran Lofthouse Master

          Is your remote machine running Linux?

          If so is there an appropriate entry in the /etc/hosts file that maps the name of the machine to the public IP address?

          • 2. Re: Local 3.6.2 Server InitialContext OK -- Remote doesn't??
            George Berish Novice

            Thanks.
            The server runs on Linux,
            And \etc\hosts contained:

            127.0.0.1 <X.org> <Z> localhost localhost.localdomain
            Where X = name of my domain, and Z = a literal name assigned to my account by the server host company.

            So, I tried to use 127.0.0.1 in four URL formats based on what I fond at 3.2.2 (Accessing JNDI over HTTP) for java.naming.provider.url at this link:
            http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch3.chapter.html
            
            A. http://127.0.0.1:8080/invoker/JMXInvokerServlet
            B. http://127.0.0.1/invoker/JMXInvokerServlet
            C. http://127.0.0.1:8080/JMXInvokerServlet
            D. http://127.0.0.1/JMXInvokerServlet
            A&C produced Screen Print I below.
            B & D produced Screen Print II.
            No luck. I hope someone can point me toward a solution.
            Note the error is thrown by this line of code after an InitialContex object seems to be instantiated
            factory = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
            I don't know if that means my problem is still with the InitialContext properties, or if my lookup () statement is bad.
            Also please note that I used C & D because of the mappings I found in /server/default/deploy/http-invoker.sar/invoker.war/WEB-INF/web.xml:
            <web-app>
             <filter>
             ...
             <init-param>
             <description>
             Do not associate this filter with the JMXInvokerServlets
             if you want unrestricted access.
             </description>
             </init-param>
             ...
             </filter>
            
            <!-- ### Servlets -->
             <servlet>
             <servlet-name>JMXInvokerServlet</servlet-name>
             <description>
             The JMXInvokerServlet receives posts containing serlized
             MarshalledInvocation objects that are routed to the invoker given by
             the the MBean whose object name hash is specified by the
             invocation.getObjectName() value. The return content is a serialized
             MarshalledValue containg the return value of the inovocation, or any
             exception that may have been thrown.
             </description>
             <servlet-class>
             org.jboss.invocation.http.servlet.InvokerServlet
             </servlet-class>
             <load-on-startup>1</load-on-startup>
             </servlet>
            
            <!-- ### Servlet Mappings -->
             <servlet-mapping>
             <servlet-name>JMXInvokerServlet</servlet-name>
             <url-pattern>/JMXInvokerServlet/*</url-pattern>
             </servlet-mapping>
             ...
            </web-app>
            Screen Print I:
            Calling InitialContext
            Naming Exception
            javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.net.Connec
            tException: Connection refused: connect]
             at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java
            :69)
            ...
             SetUp Done.
            Press any key to continue . . .
            Screen Print II:
            Calling InitialContext
            Naming Exception
            javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.io.FileNot
            FoundException: http://127.0.0.1/invoker/JMXInvokerServlet]
             at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java
            :69)
            ...
            SetUp Done.
            Press any key to continue . . .
            Any help would be appreciated.



            • 3. Re: Local 3.6.2 Server InitialContext OK -- Remote doesn't??
              Darran Lofthouse Master

              Can you try replacing the 127.0.0.1 IP address in your /etc/hosts file with the public IP address of the Linux server instead of the loopback address.



              • 4. Re: Local 3.6.2 Server InitialContext OK -- Remote doesn't??
                George Berish Novice

                A company named eApps hosts a virtual jboss 3.2.6 server for me, so I doubt if I can do what you suggest, and I can't check until Monday.

                I will post when I find out.