1 Reply Latest reply on Mar 9, 2011 9:10 PM by dish13

    Inject component (JavaBean) inside an stateless EJB component fails

    dish13

      Hello,


      I have an application with several EJB components and a JavaBean component. The JavaBean component has an application scope and there is a stateless EJB injected to it.




      @Name("selection")
      @Scope(ScopeType.APPLICATION)
      public class AppSelection implements Serializable{
      
           private static final long serialVersionUID = 1L;
           @In
           private Selection selectionMngr;





      @Stateless
      @Name("selectionMngr")
      @AutoCreate
      @Interceptors( { org.jboss.seam.ejb.SeamInterceptor.class })
      public class SelectionBean implements Selection {




      Everything works great while the selection component is called from a JSF page but when I try:


      SelectionProvider selection = (SelectionProvider) Component
                               .getInstance("selection",ScopeType.APPLICATION,true);



      I get the exception:



      Caused by: javax.ejb.EJBTransactionRolledbackException: EJB Exception: ; nested exception is: org.jboss.seam.InstantiationException: Could not instantiate Seam component: selectionMngr
           at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:794)
           at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:486)
           at weblogic.ejb.container.internal.BaseLocalObject.postInvokeTxRetry(BaseLocalObject.java:424)
           at weblogic.ejb.container.internal.StatefulLocalObject.postInvokeTxRetry(StatefulLocalObject.java:86)
           at com.cf2.management.ChannelManagementActionBean_507n28_ChannelManagementActionImpl.save(ChannelManagementActionBean_507n28_ChannelManagementActionImpl.java:901)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
           at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:43)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
           at org.javassist.tmp.java.lang.Object_$$_javassist_seam_9.save(Object_$$_javassist_seam_9.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
           at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
           at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
           at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
           at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
           at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
           at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
           ... 41 more




      As it can be seen from the exception my app server is Weblogic, version 10.3. I really don't have any clue.

        • 1. Re: Inject component (JavaBean) inside an stateless EJB component fails
          dish13

          The problem was that I was calling AppSelection selection = (AppSelection) Component
                                   .getInstance("selection",ScopeType.APPLICATION,true);
          from another EJB component so I was indirectly calling an EJB from another EJB.


          I had to make the Selection bean available to the caller EJB context.


          In the ejb-jar.xml I added:



              <session>
                <ejb-name>CallerBean</ejb-name>
                <ejb-class>org.test.CallerBean</ejb-class>
                <ejb-local-ref>
                  <ejb-ref-name>ejb/SelectionBean/local</ejb-ref-name>
                  <ejb-ref-type>Session</ejb-ref-type>
                  <local>org.test.Selection</local>
                </ejb-local-ref>
              </session>