5 Replies Latest reply on Apr 3, 2003 12:33 PM by kkennelly

    JNDI lookup returns null for remote clients

    kkennelly

      Hi,

      I am having trouble with a remote Swing application accessing JBoss. When the client runs on the same machine as the the one JBoss is running on, everything is OK. However I'm receiving a null reference on the JNDI lookup when the client is on a different machine.

      ENVIRONMENT:
      Java: JDK 1.3.1
      OS: Windows 2000
      JBOSS: 3.0

      Hosts file:
      127.0.0.1 localhost
      10.144.1.1 myhost

      code snippet:
      Properties properties = new Properties();
      properties.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      properties.setProperty("java.naming.provider.url","jnp://localhost:1099/");
      properties.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

      InitialContext = new InitialContext(properties);

      EjbTestHome ejbTestHome = (EjbTestHome)javax.rmi.PortableRemoteObject.narrow(context.lookup("TestEJB"),EjbTestHome.class);

      When I run the application on a remote machine the url is changed to:

      properties.setProperty("java.naming.provider.url","jnp://myhost:1099/");

      Any help with this would be greatly appreciated.

      Keith

        • 1. Re: JNDI lookup returns null for remote clients
          jcordonn

          Hi,

          Just take a look at your code. You should replace

          Properties properties = new Properties();
          ....
          properties.setProperty("java.naming.provider.url","jnp://localhost:1099/");

          by
          properties.setProperty("java.naming.provider.url","jnp://myhost:1099/");

          /Joel

          • 2. Re: JNDI lookup returns null for remote clients
            kkennelly

            When I run the client on the remote machine I do change the property to:

            properties.setProperty("java.naming.provider.url","jnp://myhost:1099/");


            The lookup still returns "null"

            • 3. Re: JNDI lookup returns null for remote clients
              jcordonn

              Hi

              I think it's not a communication problem to your remote naming service. I don't know the ejb-name and jndi-name you give to your bean, then i can't help you.

              Send your deployment descritors.

              /Joel

              • 4. Re: JNDI lookup returns null for remote clients
                kkennelly

                Here are my deployment descriptors for one of my session beans:

                >>>>> ejb-jar.xml


                <![CDATA[MedInst Session Bean]]>
                <display-name>Test Session EJB</display-name>

                <ejb-name>com/MedSelect/MedInst/server/ejb/TestSession</ejb-name>

                com.MedSelect.MedInst.server.ejb.TestSessionHome
                com.MedSelect.MedInst.server.ejb.TestSession
                <ejb-class>com.MedSelect.MedInst.server.ejb.TestSessionEJB</ejb-class>
                <session-type>Stateless</session-type>
                <transaction-type>Container</transaction-type>

                <env-entry>
                <env-entry-name>DataSourceName</env-entry-name>
                <env-entry-type>java.lang.String</env-entry-type>
                <env-entry-value>MySqlDS</env-entry-value>
                </env-entry>




                >>>>>> jboss.xml


                <ejb-name>com/MedSelect/MedInst/server/ejb/TestSession</ejb-name>
                <jndi-name>miTestSessionEJB</jndi-name>



                ------------------------------

                In my client code I do a lookup on "miTestSessionEJB"

                • 5. Re: JNDI lookup returns null for remote clients
                  kkennelly

                  I discovered what the problem was. It turns out the server JBoss was running on has two network connections and the Naming Service was listening on the second address instead of the first.