5 Replies Latest reply on Jul 14, 2008 4:26 PM by cyxs

    Unable to inject jndi dependency: EJBContext not bound

    amehn

      Hi!


      Im trying to test my stateful session bean with SeamTest (testng). I got an Exception when running the following line in my Testclass:




      setValue("#{c_musterprodukt.newMprName}", "MyName"); 
      //c_musterprodukt is the name of my session bean




      The Exception is:



      java.lang.RuntimeException: Unable to inject jndi dependency: env/org.mydomain.musterprodukt.impl.MusterproduktConversationBean/ctx into property org.mydomain.musterprodukt.impl.MusterproduktConversationBean.ctx: EJBContext not bound
              at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:77)
              at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:89)


      What can be the cause of this?


      Thanks in advance,


      Andreas


        • 1. Re: Unable to inject jndi dependency: EJBContext not bound
          admin.admin.email.tld

          when you deploy the app, view the console/log to see if the SFSB in question is being deployed properly and its JNDI reference is available.  Then check the JNDI address to see if matches the above or not (you can also use jboss jmx-console I think to check).

          • 2. Re: Unable to inject jndi dependency: EJBContext not bound
            amehn

            Arbi Sookazian wrote on Jul 08, 2008 01:52:


            when you deploy the app, view the console/log to see if the SFSB in question is being deployed properly and its JNDI reference is available.  Then check the JNDI address to see if matches the above or not (you can also use jboss jmx-console I think to check).



            Thanks for your answer.


            The deployment works without errors, the deployed application works too (well, not perfect, but runs).



            Thats the corresponding output during deployment:



            13:02:34,787 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=JBoss_rwb-ear.ear,jar=JBoss_rwb-ejb.jar,name=MusterproduktConversationBean,service=EJB3 with dependencies:
            13:02:34,787 INFO  [JmxKernelAbstraction]      jboss.j2ee:ear=JBoss_rwb-ear.ear,jar=JBoss_rwb-ejb.jar,name=RWBMusterproduktServiceFacade,service=EJB3
            
            13:02:34,803 INFO  [EJBContainer] STARTED EJB: org.mydomain.MusterproduktConversationBean ejbName: MusterproduktConversationBean
            
            13:02:39,568 INFO  [Component] Component: c_musterprodukt, scope: CONVERSATION, type: STATEFUL_SESSION_BEAN, class: org.mydomain.MusterproduktConversationBean, JNDI: JBoss_rwb-ear/MusterproduktConversationBean/local 




            Thats the corresponding output of jndiview of the jmx-console:


             +- JBoss_rwb-ear (class: org.jnp.interfaces.NamingContext)
              |   +- MusterproduktConversationBean (class: org.jnp.interfaces.NamingContext)
              |   |   +- localStatefulProxyFactory (class: org.jboss.ejb3.stateful.StatefulLocalProxyFactory)
              |   |   +- local (class: java.lang.Object)
            



            Can anyone help?

            • 3. Re: Unable to inject jndi dependency: EJBContext not bound
              amehn

              I found the cause of the Exception. It is the following code in my SessionBean:


                 


              @Resource 
              SessionContext ctx;




              I commented this and all occurences of ctx out, and the test runs now.
              But I need the SessionContext for Rollbacktransactions by calling:




              ctx.getRollbackOnly ();
              // or
              ctx.setRollbackOnly ();




              How can I inject SessionContext without @Resource, or how can I use rollBack Transactions without SessionCentext? How can I solve this problem?


              Thanks in advance!


              Andreas

              • 4. Re: Unable to inject jndi dependency: EJBContext not bound
                admin.admin.email.tld

                Have you tried this?


                @In private Context sessionContext;

                • 5. Re: Unable to inject jndi dependency: EJBContext not bound
                  cyxs

                  This would be the wrong Context.


                  The context Andreas ist looking for is
                     
                      javax.ejb.SessionContext


                  and not


                      org.jboss.seam.contexts.Context