5 Replies Latest reply on Nov 3, 2009 10:09 PM by cash1981

    Jboss Seam Context Lookup Erros

    tiagoff
      Hello,

      I have a strange problem using the Jboss Seam 2.2.0 GA*
      *I tried everything before sent this message to this forum

      For explain my problem, i will expose bellow all details.

      1) Architecture :

         ViewService - SessionBean - DAO - JPA


      2) Classes :

      @Name("viewService")
      ViewService {
        @In("categorySessionBean")
        private ICategorySessionBean categorySessionBean;
      }


      @Stateless
      @Name("categorySessionBean")
      public class CategorySessionBean implements ICategorySessionBean {
        @In(create = true)
        private CategoryDAO categoryDao;
      }

      @Name("categoryDao")
      public class CategoryDAO {Problem : My Action never find the registered Components. @In

        @In(create = true)
        protected EntityManager em;
      }


      3) Enviroment :

         Eclipse (3.4.2) + Maven + WTP 2.0 + Jboss AS 5.1.0.GA


      Well..

      Always that I try lookup the SessioBean in ViewService, the Jboss show me a Exception : "@In attribute requires non-null value: ViewService.categorySessionBean"
      I discovered that Jboss Seam has a class (org.jboss.seam.init.Initialization) which responsible to startup all component (written @Name) in application.

      When this Initialization class is running, this class add a suffix (Initialization.COMPONENT_SUFFIX) in the @Name of my component, so When I try lookup the component (in Context) is not possible, because this suffix was included in the real name.

      Someone know what wrong I am doing ? :S

      Thanks for your help.
        • 1. Re: Jboss Seam Context Lookup Erros
          swd847

          Try:


          
          @Name("viewService")
          ViewService {
            @In(value="categorySessionBean",create=true)
            private ICategorySessionBean categorySessionBean;
          }
          
          



          Don't worry about the COMPONENT_SUFFIX stuff, it stores information about the component, not an instance of the component.

          • 2. Re: Jboss Seam Context Lookup Erros
            tiagoff

            Thanks Stuart, works !

            • 3. Re: Jboss Seam Context Lookup Erros
              cash1981

              Stuart Douglas wrote on Nov 03, 2009 01:46:


              Try:

              
              @Name("viewService")
              ViewService {
                @In(value="categorySessionBean",create=true)
                private ICategorySessionBean categorySessionBean;
              }
              
              



              Don't worry about the COMPONENT_SUFFIX stuff, it stores information about the component, not an instance of the component.


              Hmmmm I thought the correct way of doing it was:



              
              @Name("viewService")
              ViewService {
                @In(value="categorySessionBean",create=true)
                private CategorySessionBean categorySessionBean;
              }
              
              


              Meaning, using the interface and not the direct implementation. Guess both will work though...

              • 4. Re: Jboss Seam Context Lookup Erros
                swd847

                My example does use the interface, and both ways wont work.

                • 5. Re: Jboss Seam Context Lookup Erros
                  cash1981

                  :O sorry Stuart. I must have suffered by temporary blindness