0 Replies Latest reply on Dec 11, 2011 2:04 PM by assen

    Weld ignores @Unwraps annotation on generated unwrapping producer methods

    assen

      Hi,


      I write a custom CDI extension that generates Producer-Methods for all DAO's used in my  application.For the bytecode code generation I use javassist.The AS is JBoss 6.0.0.


      All the DAO's are used in stateless beans.Because of this and because of very specific initialization process of the DAO's (that also can vary at runtime), the unwrapping producer methods are the only suitable option for me (i.e. producer methods annotated with @Unwraps instead of @Produces).


      Unfortunately I get


       WELD-001408 Unsatisfied dependencies for type xxxDao ...
      


      when I try to deploy my application.


      The very strange thing is, that if I replace @Unwraps with @Produces, so that the generated producers are annotated with @Produces, the application is deployed without problems and all works as expected (ignoring the fact that this way I lose the full control over the initialization process of the DAO's).


      It looks like the @Unwraps annotation is ignored at runtime, when it is used on methods that are generated on BeforeBeanDiscovery-Event.


      Curiously enough, I am also able to put @Produces and @Unwraps together on the generated methods and deploy the application without errors (what whould result in WELD-001409 Ambiguous dependencies for type ... if I do it the normal way). This fact confirms my suggestion, that @Unwraps is ignored.



      Can someone help me with this issue?