9 Replies Latest reply on Jul 20, 2005 9:24 AM by cinimod

    why is my LocalBean not bound?

    cinimod

      Hi,

      i have a problem working with a LocalBean that i call from a servlet.

       jndi = new InitialContext();
      WiseSessionHomeLocal localHome = (WiseSessionHomeLocal) jndi.lookup("java:comp/env/WiseSessionHomeLocal"); //load the bean
      


      The log says that the name of my bean is not bound - but everything is ok considering the jboss-web.xml and ejb-jar.xml:

      <?xml version="1.0"?>
      
       <jboss>
       <enterprise-beans>
      
       <session>
       <ejb-name>WiseSessionBean</ejb-name>
       <local-jndi-name>WiseSessionHomeLocal</local-jndi-name>
       </session>
      
       </enterprise-beans>
      
       </jboss>
      


      <session>
       <ejb-name>WiseSessionBean</ejb-name>
       <local-home>beans.session.WiseSessionHomeLocal</local-home>
       <local>beans.session.WiseSessionLocal</local>
       <ejb-class>beans.session.WiseSessionBean</ejb-class>
       <session-type>stateful</session-type>
       <reentrant>false</reentrant>
       <cmp-version>2.x</cmp-version>
       <abstract-schema-name>WiseSession</abstract-schema-name>
       <security-identity><use-caller-identity/></security-identity>
      </session>
      


      is this a problem depending on jboss? I am using version 4.0.0

      Thanks for any suggestions how to solve this problem.

        • 1. Re: why is my LocalBean not bound?
          darranl

          You are trying to lookup the bean in the local namespace of the web application, you need to add an ejb-local-ref in the web.xml of your web application.

          • 2. Re: why is my LocalBean not bound?
            cinimod

            ok, i did add the following in the web.xml:

             <ejb-local-ref>
             <ejb-ref-name>WiseSessionHomeLocal</ejb-ref-name>
             <ejb-ref-type>Session</ejb-ref-type>
             <local-home>beans.session.WiseSessionHomeLocal</local-home>
             <local>beans.session.WiseSessionLocal</local>
             <ejb-link>WiseSessionBean</ejb-link>
             </ejb-local-ref>


            But when i deploy the log tells me a NamingException:
            ejb-local-ref: "WiseSessionBean", with web.xml ejb-link: "WiseSessionBean" failed to resolve to an ejb with a LocalHome.

            As you can see above the <ejb-link> value is the same as the <ejb-name> value in ejb-jar.xml, shown in my first post.

            what´s the problem and how to solve it?

            Thanks for any suggestions.

            • 3. Re: why is my LocalBean not bound?
              darranl

              Are your two archives packaged in an ear or are both archives deployed intependently?

              • 4. Re: why is my LocalBean not bound?
                cinimod

                the .jar and .war are both contained in the same ear file.

                Any ideas how to solve this?

                • 5. Re: why is my LocalBean not bound?
                  cinimod

                  ok, i change the following:

                  now:

                  <ejb-ref-name>WiseSessionBean</ejb-ref-name>
                  <ejb-link>WiseSessionHomeLocal</ejb-link>
                  

                  i had it just the other way round...


                  also i added this to the jboss-web.xml
                  <ejb-local-ref>
                   <ejb-ref-name>WiseSessionBean</ejb-ref-name>
                   <local-jndi-name>WiseSessionHomeLocal</local-jndi-name>
                   <ejb-link>WiseSessionBean</ejb-link>
                   </ejb-local-ref>
                  


                  deployment works, but when i run the application the log says:

                  javax.naming.NameNotFoundException: WiseSessionHomeLocal not bound.

                  What´s wrong?


                  • 6. Re: why is my LocalBean not bound?
                    darranl

                    If you are using <ejb-link> and the jar and war are in the same ear you do not need to add the <ejb-local-ref> to the jboss-web.xml - Just leave this out and the name of the bean will be used to locate it.

                    Are you getting any other errors on deployment, I have just noticed that you have a number of CMP specific elements within your session bean declaration that should not be there.

                    • 7. Re: why is my LocalBean not bound?
                      cinimod

                      is the name of my jar where i put the bean classes in, of importance?

                      • 8. Re: why is my LocalBean not bound?
                        cinimod

                        ok, here are all the relevant deployment descriptors - updated:

                        part of ejb-jar.xml

                         <session>
                         <ejb-name>WiseSessionBean</ejb-name>
                         <local-home>beans.session.WiseSessionHomeLocal</local-home>
                         <local>beans.session.WiseSessionLocal</local>
                         <ejb-class>beans.session.WiseSessionBean</ejb-class>
                         <session-type>Stateful</session-type>
                         <transaction-type>Container</transaction-type>
                         <security-identity><use-caller-identity/></security-identity>
                         </session>
                        


                        jboss.xml:
                         <jboss>
                         <enterprise-beans>
                        
                         <session>
                         <ejb-name>WiseSessionBean</ejb-name>
                         <local-jndi-name>WiseSessionHomeLocal</local-jndi-name>
                         </session>
                        
                         </enterprise-beans>
                        
                         </jboss>
                        


                        part of web.xml:
                         <ejb-local-ref>
                         <ejb-ref-name>WiseSessionHomeLocal</ejb-ref-name>
                         <ejb-ref-type>Session</ejb-ref-type>
                         <local-home>beans.session.WiseSessionHomeLocal</local-home>
                         <local>beans.session.WiseSessionLocal</local>
                         <ejb-link>WiseSessionBean</ejb-link>
                         </ejb-local-ref>
                        


                        Deployment works fine, but as soon as my servlet runs, trying to call up the bean it tells me again:
                        javax.naming.NameNotFoundException: WiseSessionHomeLocal not bound.




                        • 9. Re: why is my LocalBean not bound?
                          cinimod

                          it works...i typed WiseSessionLocalHome instead of WiseSessionHomeLocal.

                          Thanks for your good advices!