1 2 Previous Next 15 Replies Latest reply on Jan 9, 2007 12:02 PM by sbublava

    Seam 1.1.0 - Injecting EJB's - Not Working

      My question is 'why doesn't this work?' - here is the background information...

      First, I have a SLSB - userEditor:

      @Stateless
      @Name("userEditor")
      public class UserEditorBean implements UserEditor {
      
       @Logger
       private Log log;
      
       @PersistenceContext(unitName = "useridDatabase")
       private EntityManager em;
      
       ... implementation details ...
      
      }
      


      Second, I have a SFSB - userManager:

      @Stateful
      @Name("userManager")
      public class UserManagerBean implements UserManager {
      
       @Logger
       private Log log;
      
       @In
       private UserEditor userEditor;
      
       @DataModel
       private List<User> users;
      
       @DataModelSelection
       @Out(required=false)
       private User user;
      
       @Factory("users")
       public void getUsers() {
       if (users == null || users.isEmpty()) {
       this.users = userEditor.getUsers();
       log.info("loaded users");
       } else {
       log.info("users already loaded");
       }
       }
      
       ... and so on ...
      }
      


      In components.xml, I have:

       <component name="org.jboss.seam.core.init">
       <property name="debug">true</property>
       <property name="myFacesLifecycleBug">false</property>
       <!-- Uncomment the following property and customize as necessary if you're using EJB3 -->
       <property name="jndiPattern">useridentity-app-1.0/#{ejbName}/local</property>
       </component>
      


      When I deploy my application .ear file, here is some (abbreviated) info from Seam:

      11:18:42,828 INFO [Component] Component: userManager, scope: CONVERSATION, type: STATEFUL_SESSION_BEAN, class: com.javaplant.identity.impl.UserManagerBean, JNDI: useri
      dentity-app-1.0/UserManagerBean/local
      .....
      11:18:43,734 INFO [Component] Component: userEditor, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: com.javaplant.identity.impl.UserEditorBean, JNDI: userident
      ity-app-1.0/UserEditorBean/local
      


      And from the JBoss JMX-CONSOLE, we have:

      Global JNDI Namespace
      
       +- useridentity-app-1.0 (class: org.jnp.interfaces.NamingContext)
       | +- Dispatcher (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy211 implements interface org.jboss.seam.core.LocalDispatcher,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
       | +- UserEditorBean (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy225 implements interface com.javaplant.identity.UserEditor,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
       | | +- remote (proxy: $Proxy224 implements interface com.javaplant.identity.UserEditor,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
       | +- UserManagerBean (class: org.jnp.interfaces.NamingContext)
       | | +- localStatefulProxyFactory (class: org.jboss.ejb3.stateful.StatefulLocalProxyFactory)
       | | +- local (class: java.lang.Object)
       | | +- remote (class: java.lang.Object)
       | | +- remoteStatefulProxyFactory (proxy: $Proxy117 implements interface org.jboss.ejb3.ProxyFactory)
      


      I have a Facelets component in which I reference the 'users' component which is produced by the factory method in my UserManager:

      <ice:dataTable
       var="user"
       value="#{users}"
       sortColumn="#{user.name}"
       >
      ....
      </ice:dataTable>
      


      However, this is not working - here is the stack trace:

      11:19:10,703 ERROR [D2DFaceletViewHandler] Problem in renderResponse: org.jboss.seam.RequiredException: In attribute requires value for component: userManager.userEdito
      r
      javax.ejb.EJBException: org.jboss.seam.RequiredException: In attribute requires value for component: userManager.userEditor
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy229.getUsers(Unknown Source)
       at com.javaplant.identity.UserManager$$FastClassByCGLIB$$5b980564.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:73)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
       at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
       at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
       at org.jboss.seam.intercept.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:82)
       at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:51)
       at com.javaplant.identity.UserManager$$EnhancerByCGLIB$$6ee2e423.getUsers(<generated>)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:102)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1791)
       at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1678)
       at org.jboss.seam.Component.getInstance(Component.java:1615)
       at org.jboss.seam.Component.getInstance(Component.java:1592)
       at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:46)
       at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:134)
       at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
       at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
       at javax.faces.component.UIData.getValue(UIData.java:1019)
       at com.icesoft.faces.component.panelseries.UISeries.getDataModel(UISeries.java:304)
       at com.icesoft.faces.component.panelseries.UISeries.processCurrentRowData(UISeries.java:132)
       at com.icesoft.faces.component.panelseries.UISeries.setRowIndex(UISeries.java:124)
       at javax.faces.component.html.HtmlDataTable.encodeBegin(HtmlDataTable.java:43)
       at com.icesoft.faces.component.panelseries.UISeries.encodeBegin(UISeries.java:245)
       at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:528)
       at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:535)
       at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:535)
       at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:535)
       at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:273)
       at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:149)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       at com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet.service(PersistentFacesServlet.java:390)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at com.javaplant.filter.RequestDumper.doFilter(RequestDumper.java:76)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at com.javaplant.cas.catalina.CASSSOAuthenticatorValve.invoke(CASSSOAuthenticatorValve.java:372)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.seam.RequiredException: In attribute requires value for component: userManager.userEditor
       at org.jboss.seam.Component.getInstanceToInject(Component.java:1876)
       at org.jboss.seam.Component.injectFields(Component.java:1342)
       at org.jboss.seam.Component.inject(Component.java:1112)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:48)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:39)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:23)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:51)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
       at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
       at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
       at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
       at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
       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:585)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       ... 107 more
      


      So what am I missing here? I could swear I've successfully injected session beans into each other before with Seam - however, I noticed the documentation doesn't show an explicit example of this... is this not supported? Any help appreciated.

      Thanks,
      Brad Smith

        • 1. Re: Seam 1.1.0 - Injecting EJB's - Not Working

          @In(create=true)?

          • 2. Re: Seam 1.1.0 - Injecting EJB's - Not Working

            Norman,

            Adding create=true as a param to the @In annotation seems to make the EJB injection work - so thanks. However...I have a bit of ranting on this ;-)

            I looked pretty carefully through the Seam documentation and I couldn't find anything (anything OBVIOUS) that explains that for the @In to work with (session) EJB's looked up from JNDI, that create must be true... (that's my rant)

            Would you care to discuss the scenario of injecting EJB session beans into each other? What's the fine print, etc.?

            Thanks,
            Brad Smith

            • 3. Re: Seam 1.1.0 - Injecting EJB's - Not Working
              kukeltje

              create does not need to be true afaik, there just has to be an instance of this object that seam can 'find' or use if you do not use @IN(required=false)

              • 4. Re: Seam 1.1.0 - Injecting EJB's - Not Working

                Exactly. @In injects a contextual variable. If an instance doesn't exist, you can optionally ask seam to create one for you.

                • 5. Re: Seam 1.1.0 - Injecting EJB's - Not Working

                  how confusing!

                  First, I'm told to set create=true, next, someone says that I don't need to set create=true, finally, I am not sure the last reply tells me anything I didn't know. I (think I) understand pretty well what is going on with @In and @Out, I've built a few apps already with Seam and made extensive use of Bijection. What I don't understand is why, after I thought I had set up Seam correctly to find my EJB's in JNDI, that it didn't seem to (until I set create = true)...

                  So, my question still stands...what's the fine print on using @In to inject a session bean, A, into another session bean, B?

                  Thanks,
                  Brad Smith

                  • 6. Re: Seam 1.1.0 - Injecting EJB's - Not Working
                    kukeltje

                    Not for me

                    • 7. Re: Seam 1.1.0 - Injecting EJB's - Not Working
                      kukeltje

                      hmm... the word 'confusing' fel out... including the rest of my response:

                      Read chapter 15.2 of the documentation. Very clear to me

                      • 8. Re: Seam 1.1.0 - Injecting EJB's - Not Working

                        Kukeltje - you must have ESP

                        15.2. Annotations for bijection

                        The next two annotations control bijection. These attributes occur on component instance variables or property accessor methods.

                        @In

                        @In

                        Specifies that a component attribute is to be injected from a context variable at the beginning of each component invocation. If the context variable is null, an exception will be thrown.

                        @In(required=false)

                        Specifies that a component attribute is to be injected from a context variable at the beginning of each component invocation. The context variable may be null.

                        @In(create=true)

                        Specifies that a component attribute is to be injected from a context variable at the beginning of each component invocation. If the context variable is null, an instance of the component is instantiated by Seam.

                        @In(value="contextVariableName")

                        Specifies the name of the context variable explicitly, instead of using the annotated instance variable name.

                        @In(value="#{customer.addresses['shipping']}")

                        Specifies that a component attribute is to be injected by evaluating a JSF EL expression at the beginning of each component invocation.

                        *

                        value ? specifies the name of the context variable. Default to the name of the component attribute. Alternatively, specifies a JSF EL expression, surrounded by #{...}.
                        *

                        create ? specifies that Seam should instantiate the component with the same name as the context variable if the context variable is undefined (null) in all contexts. Default to false.
                        *

                        required ? specifies Seam should throw an exception if the context variable is undefined in all contexts.


                        Where in this documentation is it stated that @In(create=true) results in looking up a reference to an EJB from JNDI? Maybe when create=true, and no instance of the named component (EJB) is available is any scope, then Seam takes that as a cue to look up the component (EJB) from JNDI - that's fine with me, I think that behavior should be explicitly added to the documentation; and add an example of this. I looked carefully through the documentation before posting this question ... so how do your responses help with understanding my initial issue or answer the questions subsequently posed?



                        • 9. Re: Seam 1.1.0 - Injecting EJB's - Not Working

                          How else do you instantiate a session bean than by looking up the factory in JNDI and getting an instance from it? I really don't understand what your issue is. I think the documentation is very clear about when new instances will be created.

                          • 10. Re: Seam 1.1.0 - Injecting EJB's - Not Working

                            For me - the disconnect is the instantiate or create concept - since I am typically asking the container to provide a reference to a bean looked up via JNDI, I don't consider my application to be instantiating or creating session beans; I thought the container takes care of creation / instantiation automatically - thus, again, I don't consider my client code which uses an EJB to ever actually create the bean. I apparently incorrectly assumed that just asking Seam to @In one session bean into another would work - it did not occur to me that I would have to ask Seam to 'create' a bean (which it really isn't doing, right? - Seam itself is '[taking a cue] to look up the component (EJB) from JNDI ' when create=true AND there is no matching reference to the desired session bean available in any of the scopes). Rather than 'create' this concept to me is still more like 'lookup' and so



                            @In(create=true)

                            Specifies that a component attribute is to be injected from a context variable at the beginning of each component invocation. If the context variable is null, an instance of the component is instantiated by Seam.


                            still doesn't express what's happening in terms that seem to me to be 'correct' - that's my issue.

                            Thanks,
                            Brad Smith

                            • 11. Re: Seam 1.1.0 - Injecting EJB's - Not Working
                              sbublava

                               


                              For me - the disconnect is the instantiate or create concept - since I am typically asking the container to provide a reference to a bean looked up via JNDI, I don't consider my application to be instantiating or creating session beans; I thought the container takes care of creation / instantiation automatically


                              I believe you may be mixing up Seam components (managed with @In) and EJB session beans (managed with @EJB), because Seam components can be (and often are) implemented as session beans.

                              Thanks,
                              Stephan


                              • 12. Re: Seam 1.1.0 - Injecting EJB's - Not Working
                                gavin.king

                                A JNDI lookup of an SFSB actually creates a new instance of that bean.

                                • 13. Re: Seam 1.1.0 - Injecting EJB's - Not Working
                                  gavin.king

                                  Note that EL references to a component *always* act like create=true. ie. if the context variable is null, Seam instantiates the component using a JNDI lookup.

                                  • 14. Re: Seam 1.1.0 - Injecting EJB's - Not Working

                                     

                                    Note that EL references to a component *always* act like create=true. ie. if the context variable is null, Seam instantiates the component using a JNDI lookup.


                                    Yes - I was going to throw this into the discussion - that on the one hand, my EL references are working 'magically', but on the other hand @In doesn't seem to share the same 'magic' when it comes to injection of session beans.

                                    One other note, when I first posted, it was a stateless session bean that I was asking Seam to @In(ject).

                                    Anyway, the discussion on this issue has been helpful in several ways - I now have a better handle on what you in the documentation. However, this discussion will probably repeat itself in some form by other users if you don't explicitly discuss this topic in the Seam documentation.

                                    Thanks,
                                    Brad Smith

                                    1 2 Previous Next