Oh yes, the spec is a little inconsistent about alternatives and producer methods. I think this is being addressed in CDI 1.1. For now, you have to annotate both the producer method and the declaring bean with @Alternative.
thanks for the answer, I do not really understand how the issue you mentionned relates to the problem.
Do you know, what did cost this new check to be implemented?
As there is a simple workaround it is not a big deal, just want to make sure that the issue does not get lost.
Note Pete's comment in that jira issue:
This looks to me like a bug in Weld (one that crept in from a pre-final spec revision) - that it checks if the declaring bean class is an alternative, and if it is, makes the producer an alternative. Can you file a WELD issue for this? I'll update the quickstart to explicitly make the producer an alternative.
So, in 1.1.6, producer methods and fields are no longer treated as alternatives just because the bean they are declared in is annotated @Alternative. You have to explicitly mark the producer method/field with @Alternative for it to actually be an alternative.
However, in order to enable the alternative producer method, you have to list the method's *declaring bean* in beans.xml (you can't list the producer method itself). And as you've already pointed out, you can't declare a bean as an <alternative> in beans.xml unless the bean is annotated with @Alternative. Therefore, there is no other way than to annotate both the producer method and the declaring bean with @Alternative and then enabling the bean through <alternative> in beans.xml.
sorry I did not read the issue carefully enough. Thanks for the answer