0 Replies Latest reply on Jun 3, 2011 2:39 PM by Richard Barabe

    Producer method not called when using @Inject on a method

    Richard Barabe Newbie

      Hello, I have a session scoped producer method, And an EJB that inject the produced object.  When, in the EJB, I use field level injection (annotate a field with @Inject), I see with debugger that the producer method is called as expected.

      But, when I replace the @Inject field with a @Inject method (CDI initializer method),  the producer method is not called.  That is the first weird thing that happens.  Please someone tell me you already had a similar problem ... :)

      The other weird thing is a bit more complicated to explain clearly ...
      The produced object is an JPA entity, which I annotated @Veto to prevent CDI to see it as a been.  So if the producer method is commented, I get a Unsatisfied dependency, wich is totally normal.  Also, if I don't make my entity @Veto and keep the producer method, I have an Ambiguous dependencies, wich again is totally logic.

      But, what I really don't understand is that in any case (injecting the produced variable in the ejb vie field or initialization method), the produced variable as seen with the debugger in the producer method is not the one really injected in my ejb. 
      In the EJB, the injected variable has always the same value as if I just did instanciate it with the new operator (it has default property values instead of the ones specified in the producer method).  How could the field be injected with another value than the one provided in the only producer method ?

      I'm using glassfish 3.1 with weld 1.1.1 Final.
      Hope someone had similar problems because, having tried many things, I'm a bit stuck now ...