[cdi-dev] Question regarding producer methods and default no-arg constructor

Michael Remijan mjremijan at yahoo.com
Fri Jan 2 11:02:09 EST 2015


Greetings,
I recently ran into a situation where I had created a producer method for an object but when Weld was starting up I got errors about something being ambiguous.  I finally tracked the issue to the fact that the bean my producer method was responsible for producing only had a default no-arg constructor.  I was able to "work around" this problem by annotating the bean as an @Alternative.  So I have a few questions.
(1)Is this expected behavior from CDI? If a bean only has the default no-arg constructor should you get an ambiguous error if you also have a producer method for the bean?
(2)Is annotating the bean as an @Alternative an acceptable "work around"?  Seems hackish to me. If not, what is the appropriate solution.
Thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20150102/a3a52093/attachment.html 


More information about the cdi-dev mailing list