9 Replies Latest reply on Feb 15, 2003 1:39 PM by Bill Smith

    JNDI

    Bill Smith Newbie

      I am using the Eclipse IDE with the integrated Jboss/Tomcat plugin. I am attempting to run a simple application and this line of code is bombing:
      ====================
      HelloServerHome theHelloHome = (HelloServerHome) ctx.lookup("ejb/HelloServer");
      =====================
      with the error message below.

      I asssume that this is a problem with the JNDI interface? Is there an XML file I need to modify in order to instanciate the server context? Would this be a jboss or Tomcat file?



      ERROR MESSAGE:
      javax.naming.CommunicationException: Receive timed out. Root exception is java.net.SocketTimeoutException: Receive timed out
      at java.net.PlainDatagramSocketImpl.receive(Native Method)
      at java.net.DatagramSocket.receive(DatagramSocket.java:670)
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:953)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1040)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:450)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:443)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at org.billsmith.tutorial.HelloClient.main(HelloClient.java:34)

        • 1. Re: JNDI
          Kenny Smith Newbie

          I'm having this exact same problem... I've got an out of the box jboss config. I deployed an ejb jar file and the messages on the console say my bean was deployed successfully. When I try to connect with a client I get the above exception.

          Any help is appreciated!

          Kenny Smith

          • 2. Re: JNDI
            Stefan Kuehn Newbie


            Hi!

            Some time ago i had problem understanding the XML-Files / JNDI myselve. As i found out how it works, i posted this message:
            http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ about setting up a Datasource (DS), but it covers the JNDI/XML-File-Problem too.

            Rgds
            Stefan

            • 3. Re: JNDI
              Lennart Petersson Novice

              Your client must have a jndi.properties somewhere in its classpath. How does it look like? There is one entry looking like this:

              java.naming.provider.url=192.168.205.193

              where you have to specify IP address of your JBoss server. Optionally add :1099 to specify port if not using default one. Can you ping your server... there seems to be some network related problem...

              /Lennart

              • 4. Re: JNDI
                ABAZIOU Newbie

                Something is missing : should be

                HelloServerHome theHelloHome = (HelloServerHome) ctx.lookup("jndi:ejb/HelloServer");

                it's what i have coded and it works for me

                PS : it is
                initial.lookup("java:comp/env/ejb/MyEntityBean");
                for session bean calling entity bean

                So you see why you must specify the lookup method (jndi:)

                • 5. Re: JNDI
                  ABAZIOU Newbie

                  Sorry i checked my sources, it's :
                  jndi/UserBean

                  Context initial = new InitialContext();
                  return (UserHome)
                  initial.lookup(jndi/UserBean);

                  As i use eclipse with Lomboz plug-in, i didn't remember exactly the value,
                  which is in the Home class :
                  public static final String JNDI_NAME="jndi/UserBean";

                  So i don't have to remember, the value to pass to the parameter.
                  return (UserHome)
                  initial.lookup(UserHome.JNDI_NAME);

                  And when i create a client with the lomboz plugin, i precise the local class and the local home class, so i have automatically the source line above coded


                  • 6. Re: JNDI
                    Juha Lindfors Master

                    it's not an issue with the lookup string (that would yield a NameNotFoundException) but is more likely to be some sort of network problem as lennart said in the previous reply.

                    hehe... värmland? In Sweden? You guys are funny... ;-)

                    • 7. Re: JNDI
                      Bill Smith Newbie

                      I have tried every suggestion and made the modifications to my code, I can see the ejb in the JMX console and I am still unable to bind to JNDI. This is very frustrating and I don't believe it should be this difficult! I am running Windows 2000 professional, I've tried running the server using the Eclipse IDE plug-in and also from the MS-DOS command line (run.bat) but to no avail. Again, the deployment is successful and I can see the bean in the JMX console under the JNDI view but still no luck. If it is a network issue, are there any procedures I can perform that might prove helpful?

                      • 8. Re: JNDI
                        Juha Lindfors Master

                        well stick to command line, IDE's will just mess you up.

                        What is the name that you are seeing in the global JNDI name space?

                        Are you running firewall software (ZoneAlarm)?

                        Are you trying to do the lookup from another process or within the server process (from another bean)?

                        • 9. Re: JNDI
                          Bill Smith Newbie

                          AHHHH YEEESSSS!

                          I figured it out! There is a mistake in the tutorial:

                          http://users.pandora.be/bert.torfs/j2ee.pdf
                          the statement should look like this:

                          HelloServerHome theHelloHome = (HelloServerHome) ctx.lookup("HelloWorldServer");

                          NOT

                          HelloServerHome theHelloHome = (HelloServerHome) ctx.lookup("ejb/HelloServer");