<div dir="ltr"><div>any thoughts? <br><br></div>Should a bean with @Specialize disable a bean even if it is disabled itself?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 19, 2015 at 10:09 AM, Emily Jiang <span dir="ltr">&lt;<a href="mailto:emijiang6@googlemail.com" target="_blank">emijiang6@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br>I have an application containing two wars.<br><br clear="all"><div>testDiffBDA.war<br></div><div>testDiffBDA.war/WEB-INF/classes/test/diff/web/FrontEndServlet.class<br><br>@Inject CounterProducerConsumerModified2 bean;<br><br><br></div><div>beans-xml-modified2.jar<br>containing one bean and an empty-ish beans.xml :<br>@Inject@CounterModifiedQualifier String modifiedProducer;<br><br>beans-xml-modified.jar.jar<br>CounterModifiedQualifier  (the interface)<br>CounterProducerModified (the bean implementing that interface)<br>AlternativeCounterProducerModified (an alternative specialized bean)<br></div><div> beans.xml<br></div><div>   &lt;alternatives&gt;<br>        &lt;class&gt;com.ibm.jcdi.test.beansxml.AlternativeCounterProducerModified&lt;/class&gt;<br>   &lt;/alternatives&gt;<br><br></div><div>My application failed deployment with the error on Weld but worked on OpenWebBeans<br><br></div><div>[ERROR   ] CWWKZ0004E: An exception occurred while starting the application testDiffBDA. The exception message was: com.ibm.ws.container.service.state.StateChangeException: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type String with qualifiers @CounterModifiedQualifier<br>  at injection point [BackedAnnotatedField] @Inject @CounterModifiedQualifier com.ibm.jcdi.test.beansxml.CounterProducerConsumerModified2.modifiedProducer<br>  at com.ibm.jcdi.test.beansxml.CounterProducerConsumerModified2.modifiedProducer(CounterProducerConsumerModified2.java:0)<br></div><div>-- <br><br><br></div><div>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.<br><br></div><div>From Weld&#39;s perspective, any bean annotated with @Specialized disables a second bean regardless whether itself is active or not.<br><br>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.<br><br><br></div><div>I also checked the spec:<br>@Alternative @Specializes<br>public class MockAsynchronousService extends AsynchronousService {<br>...<br>}<br>When an enabled bean, as defined in Section 5.1.2, “Enabled and disabled beans”, specializes<br>a second bean, we can be certain that the second bean is never instantiated or called by the<br>container. Even if the second bean defines a producer or observer method, the method will never<br>be called.<br><br></div><div>The spec says only an enabled bean can specialize a second bean. I would like to know what other people think.<br></div><div><br></div><div><br>Thanks<br>Emily<br>=================<span class="HOEnZb"><font color="#888888"><br>Emily Jiang<br><a href="mailto:ejiang@apache.org" target="_blank">ejiang@apache.org</a><br></font></span></div><div>
</div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Thanks<br>Emily<br>=================<br>Emily Jiang<br><a href="mailto:ejiang@apache.org" target="_blank">ejiang@apache.org</a><br></div>
</div>