6 Replies Latest reply on Oct 24, 2007 6:37 AM by nickarls

    @In gets not injected thou it exists

    axismundi

      in one particular case the @In annotation is not working here.

      @Stateful
      @Name("shopTree")
      @Scope(ScopeType.SESSION)
      public class ShopTreeBean implements ShopTree {
       @In
       private ApplicationUser applicationUser; <-- ALWAYS NULL
      


      I have verified that ApplicationUser applicationUser IS existing in the Seam session-context, and it is not null. No exception (such as In-property required) is occuring.
      Anyone has any idea why Seam (2.0CR1) is not injecting this session-property?
      It is rather annoying if this injection-mechanism works sometimes, and sometimes not.

        • 1. Re: @In gets not injected thou it exists
          yilmaz_

          "private ApplicationUser" this must be interface
          and "applicationUser" this must be component name @Name( "applicationUser" )

          alsa you can use @In(create=true)

          • 2. Re: @In gets not injected thou it exists
            axismundi

            thanks for your input.
            the component declaration surely doesn't need to be an interface.

            I added @Name("applicationUser") to my ApplicationUser class, but still it is not being injected. And anyway, the component "applicationUser" IS in fact existing in the Seam session-ctx (according to Seam debug-page).

            Secondly, and even more strange, the injection for applicationUser works well in another SFSB:

            @Stateful
            @Name("orderManagement")
            @Scope(ScopeType.SESSION)
            public class OrderManagementBean implements OrderManagement {
            
             @In
             private ApplicationUser applicationUser; <-- gets injected properly!
            
            ----------------
            @Stateful
            @Name("shopTree")
            @Scope(ScopeType.SESSION)
            public class ShopTreeBean implements ShopTree {
            
             @In
             private ApplicationUser applicationUser; <-- NOT injected !



            yes, both EJBs run in the same application.

            By the way, the applicationUser component is put into session-ctx by the authentication class via @Out-jection.

            • 3. Re: @In gets not injected thou it exists
              axismundi

              a few debug lines before the error occurs, Seam logs

              DEBUG [org.jboss.seam.Component] trying to inject with hierarchical context search: applicationUser
              DEBUG [org.jboss.seam.contexts.Contexts] found in session context: applicationUser


              Unfortunely the message doesn't refer to the component to which it is injecting.

              • 4. Re: @In gets not injected thou it exists
                nickarls

                Could there be a non-required outjection somewhere that could overwrite it before the call?

                • 5. Re: @In gets not injected thou it exists
                  axismundi

                   

                  "nickarls" wrote:
                  Could there be a non-required outjection somewhere that could overwrite it before the call?


                  The applicationUser is @Out-jected only once, that is in the authenticator class, which has EVENT-scope and should not be called.

                  @Name("authenticator")
                  @Scope(ScopeType.EVENT)
                  public class Authenticator implements Serializable {
                  
                   @Out(scope=ScopeType.SESSION)
                   private ApplicationUser applicationUser;
                  
                  


                  • 6. Re: @In gets not injected thou it exists
                    nickarls

                    Can you access the correct instance with Contexts.lookupInStatefulContexts(...)?