3 Replies Latest reply on Oct 9, 2008 11:38 AM by David Doherty

    org.jboss.seam.Component.instantiateSessionBean() jndiName fails

    David Martin Newbie
      Hello,

      I am having problems injecting a seam component (a stateful session bean) into another seam component (also a stateful session bean)using the @In annotation. 

      I'm getting the following exceptions:

      javax.naming.NameNotFoundException: java:comp/env/jmat/MyListBean/local not found
      Which then leads to the following exception:
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: myList

      I have configured the jndi-pattern in the component.xml as follows:

      <core:init debug="true" jndi-pattern="java:comp/env/myProj/#{ejbName}/local"/>

      After tediously going step by step using the debugger, I finally found where in the seam api the jndi call is made - Component.instantiateSessionBean().  The interesting thing is if I change the jndiName variable (in the Component class) while in debug from this value:

      java:comp/env/myProj/MyListBean/local

      To this value:

      myProj/MyListBean/local

      The lookup succeeds.

      I am using Seam 2.0.1-GA and deploying to the OC4J 11 application server.  I have the EJB setup in the web.xml as follows:

      <ejb-local-ref>
      <ejb-ref-name>myProj/MyListBean/local</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <local>myProj.action.MyList</local>
           <ejb-link>MyListBean</ejb-link>
      </ejb-local-ref>

      Please note that Seam finds this bean with no problems if I bind it to a richfaces component (as an example).  The problem only happens when I invoke a Seam component that has another Seam component injected.  I also confirmed via the OC4J Admin console that the EJB did indeed deploy properly.

      Any help would be greatly appreciated.
        • 1. Re: org.jboss.seam.Component.instantiateSessionBean() jndiName fails
          David Martin Newbie

          David Martin wrote on Feb 14, 2008 04:46 AM:


          Hello,

          I am having problems injecting a seam component (a stateful session bean) into another seam component (also a stateful session bean)using the @In annotation. 

          I'm getting the following exceptions:


          javax.naming.NameNotFoundException: java:comp/env/jmat/MyListBean/local not found
          Which then leads to the following exception:
          org.jboss.seam.InstantiationException: Could not instantiate Seam component: myList




          I have configured the jndi-pattern in the component.xml as follows:


          <core:init debug="true" jndi-pattern="java:comp/env/myProj/#{ejbName}/local"/>
          



          After tediously going step by step using the debugger, I finally found where in the seam api the jndi call is made - Component.instantiateSessionBean().  The interesting thing is if I change the jndiName variable (in the Component class) while in debug from this value:


          java:comp/env/myProj/MyListBean/local




          To this value:


          myProj/MyListBean/local




          The lookup succeeds.

          I am using Seam 2.0.1-GA and deploying to the OC4J 11 application server.  I have the EJB setup in the web.xml as follows:


          <ejb-local-ref>
          <ejb-ref-name>myProj/MyListBean/local</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
                <local>myProj.action.MyList</local>
               <ejb-link>MyListBean</ejb-link>
          </ejb-local-ref>




          Please note that Seam finds this bean with no problems if I bind it to a richfaces component (as an example).  The problem only happens when I invoke a Seam component that has another Seam component injected.  I also confirmed via the OC4J Admin console that the EJB did indeed deploy properly.

          Any help would be greatly appreciated.



          Click HELP for text formatting instructions. Then edit this text, this live preview updates if you stop typing for 3 seconds.

          • 2. Re: org.jboss.seam.Component.instantiateSessionBean() jndiName fails
            David Martin Newbie

            The problem has been solved (thanks to mirko27).


            I had to place the following in my ejb-jar.xml:



            <enterprise-beans>
                    <session>
                        <ejb-name>MyManagerBean</ejb-name>
                        <ejb-class>myproj.action.MyManagerBean</ejb-class>
                     <ejb-local-ref>
                         <ejb-ref-name>myProj/MyListBean/local</ejb-ref-name>
                            <ejb-ref-type>Session</ejb-ref-type>
                           <local>myproj.action.MyList</local>
                           <ejb-link>MyListBean</ejb-link>
                        </ejb-local-ref>
                    </session>
            </enterprise-beans>



            Where MyListBean is the stateful session bean that is injected into the stateful session bean MyManagerBean.

            • 3. Re: org.jboss.seam.Component.instantiateSessionBean() jndiName fails
              David Doherty Newbie

              Hi David,


              I've seen a fair few posts about beans not being bound. I am having the same problem at the moment. I thought one of the advantages of seam was that you didn't have to manage all the bean declarations in the xml, as this was done via annotations on the classes themselves?


              I'm just wondering if you ever managed to get to the bottom of this problem?


              It seems to me that maybe the bean is being declared and pooled with this configuration and maybe the seam framework is also instantiating the bean using a different jndi name?


              As a newcomer to seam, I'm trying to find my feet so if I'm wrong don't hesitate to put me back on the right path.


              Thanks,
              Dave