[cdi-dev] Question regarding producer methods and default no-arg constructor
radim.hanus at gmail.com
Fri Jan 2 16:58:34 EST 2015
you may also consider the following possibilities:
1) the class defining producer method is not a bean itself (in CDI 1.2 use
beans.xml with both version 1.1 and bean-discovery-mode of annotated and
don't apply any bean defining annotation)
2) define a qualifier and use it either on bean or producer method in
conjunction with inject
2015-01-02 17:02 GMT+01:00 Michael Remijan <mjremijan at yahoo.com>:
> 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.
> 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?
> Is annotating the bean as an @Alternative an acceptable "work around"?
> Seems hackish to me. If not, what is the appropriate solution.
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> Note that for all code provided on this list, the provider licenses the
> code under the Apache License, Version 2 (
> http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other
> intellectual property rights inherent in such information.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cdi-dev