[cdi-dev] Clarification on 4.3 Specialization

Emily Jiang emijiang6 at googlemail.com
Thu Nov 19 05:09:47 EST 2015

I have an application containing two wars.


@Inject CounterProducerConsumerModified2 bean;

containing one bean and an empty-ish beans.xml :
@Inject at CounterModifiedQualifier String modifiedProducer;

CounterModifiedQualifier  (the interface)
CounterProducerModified (the bean implementing that interface)
AlternativeCounterProducerModified (an alternative specialized bean)


My application failed deployment with the error on Weld but worked on

[ERROR   ] CWWKZ0004E: An exception occurred while starting the application
testDiffBDA. The exception message was:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied
dependencies for type String with qualifiers @CounterModifiedQualifier
  at injection point [BackedAnnotatedField] @Inject

After further investigation and talking to Martin from Weld, the error was
caused due to the fact of AlternativeCounterProducerModified disabling the
CounterProducerModified bean but itself is not enabled in the jar of
beans-xml-modified2.jar. Therefore, no producer is active to produce a bean
with the qualifier CounterModifiedQualifier.

>From Weld's perspective, any bean annotated with @Specialized disables a
second bean regardless whether itself is active or not.

My understanding is that the specialized should only take effect if itself
is enabled. Otherwise, we run into the situation of where the specialized
bean is not enabled but it disabled another bean. To me, it is wrong.

I also checked the spec:
@Alternative @Specializes
public class MockAsynchronousService extends AsynchronousService {
When an enabled bean, as defined in Section 5.1.2, “Enabled and disabled
beans”, specializes
a second bean, we can be certain that the second bean is never instantiated
or called by the
container. Even if the second bean defines a producer or observer method,
the method will never
be called.

The spec says only an enabled bean can specialize a second bean. I would
like to know what other people think.

Emily Jiang
ejiang at apache.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20151119/8eb649d8/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testDiffBDA.war
Type: application/octet-stream
Size: 7618 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/cdi-dev/attachments/20151119/8eb649d8/attachment.obj 

More information about the cdi-dev mailing list