Discussions

EJB programming & troubleshooting: Error: javax.naming. ..... Bean not bound.

  1. Hi !

    My problem is, when i try to access my EntityBean thru WebClient (Servlet), i get "javax.naming ...... SectionBean not bound".

    I had carefully double check that my bean is bound with the same name (SectionBean), in my deployment descriptor, <ejb-name>SectionBean</ejb-name>, as in the lookup() method.

    I`ve been hunting for the solution for 2 days now. Plz can anyone help me out here.

    I am using JBoss-Final-3.0.0 with Tomcat-Final-4.0.0. Tomcat is running on 8085 and JBoss on default port.

    Looking Forward

    Relatively new to EJB ...
  2. <ejb-name> tag does not define the JNDI name of your bean. It is just a logical name given to your EJB.

    Assuming in your file ejb-jar.xml you have defined your bean with the logical name called SectionBean (using the tag <ejb-name>SectionBean</ejb-name>) , you need to provide other information in another file called jboss.xml (the file name and contents is EJB container specific. With JBoss , it is jboss.xml . With Weblogic , it is weblogic-ejb-jar.xml)

    In your jboss.xml is the place where you give the JNDI name for your bean. Look at the example below. That is roughly what you should have defined in jboss.xml

    <jboss>
         <secure>true</secure>
         <container-configurations />
         <resource-managers />
         <enterprise-beans>
           <entity>
    <ejb-name>SectionBean</ejb-name>
    <jndi-name>SectionBean</jndi-name>
    <configuration-name></configuration-name>
           </entity>
         </enterprise-beans>
    </jboss>

    Note that you should provide the EJB's logical name here as well (within the tag <ejb-name>). The logical name should map to what you have defined in ejb-jar.xml . The JNDI name is given within the <jndi-name> tag. You can change it to ,let's say <jndi-name>FooBean</jndi-name>. If you do that , you can look up the bean using the JNDI name "FooBean"

    Hope the above helps.