1 Reply Latest reply on Oct 21, 2009 1:20 AM by kragoth

    Seam is desinjecting components injected with @in

    mcsous

      Hello,


      I'm facing a really straight problem with seam injection. I just create a project using seam generator 2.2 with Jboss Tools and I create the following components


      TestBean1


      @Name("test1") 
      public class Test1 {
          public String sayHello() {
             return "hello";
          }
      }



      TestBean2


      @Name("test2") 
      public class Test2 {
         @In
         private Test1 test1;
      
         public Test1 getTest1() {
           return test1;
         }
      }




      TestBean


      @Name("testBean") 
      public class TestBean {
         @In
         private Test2 test2;
      
         public void say() {
            test2.getTest1().sayHello();
         }
      }



      When I run the expression {testBean.say} it throws a NullPointExeception because test1 wasn't injected.


      ps: I debugged de Component.getInstance() and it desinject the bean before returning the instance.


      Is there anything to solve this?






        • 1. Re: Seam is desinjecting components injected with @in
          kragoth

          I believe you will find that this is related to the JIRA I raised recently.
          https://jira.jboss.org/jira/browse/JBSEAM-4438


          The issue you are having is fairly fundamental to the system and can cause a lot of frustration and confusion. I would expect that this sort of bug be addressed fairly quickly.


          Unfortunately it appears that most(all) of the Seam guys are so caught up in Weld or whatever it is getting called these days that very little is being done to address the issues that a lot of us are having with the existing library. I've raised 2 JIRAs over the past month or so and neither of them have received any attention. Not even a comment. My guess is that the only way these issues will be fixed is if you prove that they exist in Seam3 or wherever the time is being spent at the moment.


          Anyways, enough of my ranting.... here's how to solve your problem.


          For the time being, to work around your issue don't use Injection. Instead access your Seam bean direcly using the Component.getInstance(class) method. This will avoid the variable being disinjected at the end of the invocation of your method.