8 Replies Latest reply on Nov 8, 2013 9:06 AM by Martin Kouba

    Injection depends on visibility of class/methdod. A bug?

    Martin Höller Newbie



      In my sample project the dependency injection doesn't work for special combinations of class-/method-visibility, which very much seems like a bug in weld to me. Maybe someone could explain the observed behavior to me.


      Here is what I have:


      • A simple, session-scoped, managed bean, that derives from an abstract base-class:



      public class MyFirstBean extends MyAbstractBean implements Serializable




      • The package private abstract base class for the bean with some injections:



      abstract class MyAbstractBean



          public void setFoo(Double f)


              System.out.println("## foo injected: " + f);




          public void init()


              System.out.println("## MyAbstractBean.init() called");


          public Double getFoo()
              return 1.2d;


      • An XHTML that uses the bean, so it definitely gets constructed.


      The methods annotated with @Inject are not called in this case! Why not?


      As soon as I change the visibility of the abstract class from package-private to public or the method visibility to package-private everything works as expected. Neither in the JSR-299 specification nor in the seam manual there is anything available that mentions visibility. Did I find a bug?


      My environment:

      • JBoss AS 7.1.1
      • JEE 6
      • Weld 1.1.16


      Many thanks in advance,

      - martin