Tuesday, January 22, 2008

Error: javax.naming. ..... Bean not bound.

<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"

No comments: