4 Replies Latest reply on May 8, 2003 11:39 AM by sys user

    javax.naming.NameNotFoundException

    sys user Master

      I will be eternally grateful if anyone can tell me how to set the jboss.xml jndi name for the ejb show below - whatever combination I do comes out with the 'not bound' error - I am listing the error message, jboss.xml, ejb-jar.xml.
      What is the syntax logic for the .... jndi name?
      THANKS!!!! !


      2003-05-07 16:28:19,750 ERROR [my-server.conductor.web.servlet.GenericView] javax.naming.NameNotFoundException:

      BookingManager not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:464)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:443)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at my-server.conductor.web.servlet.Controller.initializeResourceCache(Controller.java:375)
      at my-server.conductor.web.servlet.Controller.init(Controller.java:99)
      at my-server.conductor.web.servlet.GenericView.init(GenericView.java:34)
      at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.java:225)
      at org.mortbay.jetty.servlet.ServletHandler.initializeServlets(ServletHandler.java:444)
      at org.mortbay.jetty.servlet.WebApplicationHandler.initializeServlets(WebApplicationHandler.java:163)
      at org.mortbay.jetty.servlet.WebApplicationContext.start(WebApplicationContext.java:492)
      at org.mortbay.j2ee.J2EEWebApplicationContext.start(J2EEWebApplicationContext.java:85)
      at org.jboss.jetty.Jetty.deploy(Jetty.java:414)
      at org.jboss.jetty.JettyService.performDeploy(JettyService.java:243)
      at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:300)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:807)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:799)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:621)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:585)
      at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      JBOSS.XML
      <?xml version = '1.0' encoding = 'windows-1252'?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">

      <enterprise-beans>

      <ejb-name>BookingManager</ejb-name>
      <jndi-name>ejb/BookingManagerHome</jndi-name>

      </enterprise-beans>


      EJB-JAR.XML
      <?xml version = '1.0' encoding = 'windows-1252'?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"

      "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>

      Session Bean ( Stateless )
      <display-name>BookingManager</display-name>
      <ejb-name>BookingManager</ejb-name>
      my-server.conductor.ejb.BookingManagerHome
      my-server.conductor.ejb.BookingManager
      <ejb-class>my-server.conductor.ejb.impl.BookingManagerBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <resource-ref>
      <res-ref-name>jdbc/PostgresDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      Entity Bean ( Container-managed Persistence )
      <display-name>Booking</display-name>
      <ejb-name>Booking</ejb-name>
      my-server.conductor.ejb.BookingHome
      my-server.conductor.ejb.Booking
      <ejb-class>my-server.conductor.ejb.impl.BookingBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>my-server.conductor.ejb.BookingPK</prim-key-class>
      False
      <cmp-field>
      <field-name>booking_id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>repeat_booking_id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>room_id</field-name>
      </cmp-field>
      <resource-ref>
      <res-ref-name>jdbc/PostgresDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

        • 1. Re: javax.naming.NameNotFoundException
          Joel Vogt Master

          are you looking up jndi 'BookingManager'? Try 'ejb/BookingManagerHome'

          • 2. Re: javax.naming.NameNotFoundException
            sys user Master

            thanks but i tried that - she no work - tried all these too:

            1 <enterprise-beans>

            <ejb-name>BookingManager</ejb-name>
            <jndi-name>ejb/BookingManagerHome</jndi-name>
            2 <enterprise-beans>

            <ejb-name>BookingManager</ejb-name>
            <jndi-name>ejb/BookingManager</jndi-name>
            3 <enterprise-beans>

            <ejb-name>BookingManager</ejb-name>
            <jndi-name>BookingManager</jndi-name>
            4 <enterprise-beans>

            <ejb-name>BookingManager</ejb-name>
            <jndi-name>BookingManager</jndi-name>

            <ejb-name>BookingManager</ejb-name>
            <jndi-name>BookingManager</jndi-name>

            • 3. Re: javax.naming.NameNotFoundException
              Joel Vogt Master

              Well okay, as long as the ejb-name is linked between the config, then the jndi should be able to be used.
              Check your log at startup, does the bean deploy okay? If it says so, check http://localhost:8080/jmx-console. See if your bean is there and bound to the jndi-name you expect.
              If this is all right and your lookup fails, you will probably need to post the code you are using for the lookup. Is this lookup in jboss' JVM or external?

              • 4. Re: javax.naming.NameNotFoundException
                sys user Master

                Thank you so much sir for your responses.
                I looked up the jndi names in the jboss console & they seem to be bound:

                jndiName=ejb/BookingManagerHome,service=EJB

                EJBModule=conductor.jar,J2EEApplication=conductor.ear,J2EEServer=Single,j2eeType=StatelessSessionBean,name=ejb/BookingManagerHome

                Yet the log still reports:

                10:18:16,677 ERROR [GenericView] javax.naming.NameNotFoundException: BookingManager not bound
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
                at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
                at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:464)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:443)
                at javax.naming.InitialContext.lookup(InitialContext.java:347)

                Does this error refer to a database connection? the application connects to a Postgres database - I know its connecting because I can see it in the Postgres log file. I have setup the postgres-service.xml etc - here's the connection code (the java:/PostgresDS is the only one that works I've tried all the rest):

                package edu.stanford.scil.conductor.ejb.util;
                import org.apache.log4j.*;
                import javax.naming.*;
                import java.rmi.*;
                import java.sql.*;
                import javax.sql.*;

                public class Util
                {
                private static Category logger = Category.getInstance(Util.class.getName());
                private static final String dataSourceName = "java:/PostgresDS";

                /** returns a JDBC Connection the the database used by the Conductor app */
                public static Connection getConnection()
                throws SQLException, RemoteException
                {
                DataSource ds = getDataSource(dataSourceName);
                return ds.getConnection();
                }

                private static DataSource getDataSource(String dsName)
                throws RemoteException
                {
                DataSource ds = null;
                try
                {
                Context ic = new InitialContext();
                ds = (DataSource) ic.lookup(dsName);
                } catch (NamingException e)
                {
                logger.error(e.toString());
                throw new RemoteException(e.getMessage());
                }
                return ds;
                }