<div dir="ltr"><div><div><div>Thanks for your replies - they are really helpful.<br> <br></div>So I think I willl be spending this morning in <br><a href="https://github.com/OpenLiberty/liberty-arquillian/blob/master/liberty-managed/src/main/java/org/jboss/arquillian/container/was/wlp_managed_8_5/WLPManagedContainer.java">https://github.com/OpenLiberty/liberty-arquillian/blob/master/liberty-managed/src/main/java/org/jboss/arquillian/container/was/wlp_managed_8_5/WLPManagedContainer.java</a><br></div>and looking at Liberty FFDC files to build some caused by exception chains in the Liberty Arquillian Container.<br><br></div><div>I have to admit I had been through the weld core&#39;s ShouldThrow logic. <br></div><div>It was really helpful to understand what the cultural concensus/expectation for<br></div><div>a TCK @ShouldThrow is, in terms of:<br><br></div><div>Q1) @ShouldThrows identify one exception but servers usually report a causal chain -<br></div><div>was it OK for the ShouldThrow exception to be in the causal chain or does it have to be<br></div><div>the &#39;top&#39; one. (and what does &#39;top&#39; mean anyway when the interface is not code but<br></div><div>a set of messages in a log.) <br>A1) Clearly it is OK - &quot;It should be thrown&quot; - so it can be a member of a set<br></div><div>that is thrown - there is no customer Java involved in catching - just log messages<br></div><div>and these log messages should clearly state, for example &quot;DefinitionException&quot;.<br></div><div><br>Q2)  In terms of the exact exception thrown was the &#39;isa&#39; (isAssignable) test acceptable?<br></div><div>(again this is code but the user interface is log messages)<br></div><div>A2) Clearly everyone uses Arquillian so that impl is the de-facto standard. However it<br></div><div>is also accepted practice that a Container or for a ExceptionTransformer might wrap<br></div><div>a, for example WELD DefinitionException with a javax.inject one - it has to<br></div><div>create 100% of the exceptions and usually wraps them up as a cause to an Arquillian <br>envelope exception anyway.<br></div><div></div><div><br></div><div>Reading the Weld code, I had thought I could get away with no ExceptionTransformer for now<br></div><div>as long as one of the causal exception chain was assignable from what was<br></div><div>sought (which I think is the case I have).<br></div><div><br></div><div>Thanks so much again - this has made my path ahead clear.<br></div><br><div>Gordon<br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 April 2018 at 07:54, Matej Novotny <span dir="ltr">&lt;<a href="mailto:manovotn@redhat.com" target="_blank">manovotn@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Martin Kouba&quot; &lt;<a href="mailto:mkouba@redhat.com">mkouba@redhat.com</a>&gt;<br>
&gt; To: &quot;Matej Novotny&quot; &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt;, &quot;Gordon Hutchison&quot; &lt;<a href="mailto:gordon.hutchison@gmail.com">gordon.hutchison@gmail.com</a>&gt;<br>
&gt; Cc: <a href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a><br>
&gt; Sent: Friday, April 27, 2018 8:41:45 AM<br>
&gt; Subject: Re: [weld-dev] CDI 2.0 TCK ObserverMethodWithoutNotifyMet<wbr>hodTest failure - ShouldThrow...Definition or<br>
&gt; Deployment Exception? - spec inconsistency??<br>
&gt; <br>
</span><span class="">&gt; Dne 27.4.2018 v 08:26 Matej Novotny napsal(a):<br>
&gt; &gt; Hi Gordon,<br>
&gt; &gt; <br>
&gt; &gt; running the test on WFLY (or actually without EE container) gives me the<br>
&gt; &gt; same stacktrace, however the test passes for me.<br>
&gt; &gt; What is it you fail on exactly?<br>
&gt; &gt; <br>
&gt; &gt; Debugging a bit shows that @ShouldThrowException annotation (which is<br>
&gt; &gt; guarding the exception in the test) goes through a whole chain of<br>
&gt; &gt; exceptions - having it wrapped should still pass the test.<br>
&gt; &gt; E.g. it looks at the cause, see if that&#39;s assignable, and if it isn&#39;t then<br>
&gt; &gt; the method is recursively invoked for Exception.getCause().<br>
&gt; &gt; Here is a link to Arq. code doing that -<br>
&gt; &gt; <a href="https://github.com/arquillian/arquillian-core/blob/master/container/impl-base/src/main/java/org/jboss/arquillian/container/impl/client/container/DeploymentExceptionHandler.java#L63-L66" rel="noreferrer" target="_blank">https://github.com/arquillian/<wbr>arquillian-core/blob/master/<wbr>container/impl-base/src/main/<wbr>java/org/jboss/arquillian/<wbr>container/impl/client/<wbr>container/<wbr>DeploymentExceptionHandler.<wbr>java#L63-L66</a><br>
&gt; <br>
&gt; <br>
&gt; In fact, we&#39;re using a customized<br>
&gt; org.jboss.arquillian.<wbr>container.spi.client.<wbr>container.<wbr>DeploymentExceptionTransformer<br>
&gt; for WildFly:<br>
&gt; <a href="https://github.com/weld/core/blob/master/jboss-tck-runner/src/test/java/org/jboss/weld/tck/wildfly8/WildFly8DeploymentExceptionTransformer.java" rel="noreferrer" target="_blank">https://github.com/weld/core/<wbr>blob/master/jboss-tck-runner/<wbr>src/test/java/org/jboss/weld/<wbr>tck/wildfly8/<wbr>WildFly8DeploymentExceptionTra<wbr>nsformer.java</a><br>
<br>
</span>Yea, I know.<br>
But this does not take effect outside WildFly where the result is the same.<br>
And even in WFLY it repacks Arquillian-specific exception (org.jboss.arquillian.<wbr>container.spi.client.<wbr>container.DeploymentException) into whatever fragment it finds in getCause().<br>
<div class="HOEnZb"><div class="h5"><br>
&gt; <br>
&gt; &gt; <br>
&gt; &gt; As for spec point of view...<br>
&gt; &gt; Wrapping those exceptions meets both criteria mentioned in spec as long as<br>
&gt; &gt; you can get to both of them.<br>
&gt; &gt; Also, having DefinitionException on top makes sense from user point of view<br>
&gt; &gt; (at least in my opinion) because is it ultimately developer&#39;s mistake that<br>
&gt; &gt; he/she did not add the notify() method.<br>
&gt; &gt; And that subsequently leads to DeploymentException.<br>
&gt; &gt; Does it make sense?<br>
&gt; &gt; <br>
&gt; &gt; I&#39;d like to help more but I am not sure whether you are battling some<br>
&gt; &gt; actual test failure or the somewhat clashing sentences in spec itself?<br>
&gt; &gt; <br>
&gt; &gt; Matej<br>
&gt; &gt; <br>
&gt; &gt; ----- Original Message -----<br>
&gt; &gt;&gt; From: &quot;Gordon Hutchison&quot; &lt;<a href="mailto:gordon.hutchison@gmail.com">gordon.hutchison@gmail.com</a>&gt;<br>
&gt; &gt;&gt; To: <a href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a><br>
&gt; &gt;&gt; Sent: Thursday, April 26, 2018 5:17:55 PM<br>
&gt; &gt;&gt; Subject: [weld-dev] CDI 2.0 TCK ObserverMethodWithoutNotifyMet<wbr>hodTest<br>
&gt; &gt;&gt; failure - ShouldThrow...Definition or<br>
&gt; &gt;&gt; Deployment Exception? - spec inconsistency??<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Hi Folks,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I work in the IBM CDI implementation team.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; We are running the CDI 2.0 TCK/CDS and get a test failure on:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; org.jboss.cdi.tck.tests.<wbr>extensions.lifecycle.broken.<wbr>observerMethod.<wbr>ObserverMethodWithoutNotifyMet<wbr>hodTest<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; that I need some advice on.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; The test has:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; import <a href="http://javax.enterprise.inject.spi.De" rel="noreferrer" target="_blank">javax.enterprise.inject.spi.De</a> ploymentException;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; @ShouldThrowException(<wbr>DeploymentException.class)<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; // unable to process ObserverMethodConfigurator due to missing notify<br>
&gt; &gt;&gt; method<br>
&gt; &gt;&gt; impl<br>
&gt; &gt;&gt; @Test<br>
&gt; &gt;&gt; @SpecAssertions({ @SpecAssertion(section = AFTER_BEAN_DISCOVERY, id =<br>
&gt; &gt;&gt; &quot;ee&quot;)<br>
&gt; &gt;&gt; })<br>
&gt; &gt;&gt; public void unableToProcessObserverMethodC<wbr>onfigurator() {<br>
&gt; &gt;&gt; }<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; This behaviour is specified in<br>
&gt; &gt;&gt; <a href="https://docs.jboss.org/cdi/spec/2.0/cdi-spec-with-assertions.html#after_bean_discovery" rel="noreferrer" target="_blank">https://docs.jboss.org/cdi/<wbr>spec/2.0/cdi-spec-with-<wbr>assertions.html#after_bean_<wbr>discovery</a><br>
&gt; &gt;&gt; (search for &quot;ee)&quot; )<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; ee) If the container is unable to process the ObserverMethodConfigurator<br>
&gt; &gt;&gt; it<br>
&gt; &gt;&gt; automatically detects the problem and treats it as a deployment problem.<br>
&gt; &gt;&gt; ObserverMethodWithoutNotifyMet<wbr>hodTest.<wbr>unableToProcessObserverMethodC<wbr>onfigurator()<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; However what we see coming back from Weld is not a javax<br>
&gt; &gt;&gt; DeploymentException<br>
&gt; &gt;&gt; but a javax DefinitionException wrapping a weld DeploymentException cause<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Stack Dump = <a href="http://javax.enterprise.inject.spi.De" rel="noreferrer" target="_blank">javax.enterprise.inject.spi.De</a> finitionException:<br>
&gt; &gt;&gt; org.jboss.weld.exceptions.<wbr>DeploymentException: WELD-000179:<br>
&gt; &gt;&gt; ObserverMethodConfigurator created by<br>
&gt; &gt;&gt; org.jboss.cdi.tck.tests.<wbr>extensions.lifecycle.broken.<wbr>observerMethod.<wbr>AfterBeanDiscoveryObserver@<wbr>d31423c<br>
&gt; &gt;&gt; cannot be processed<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.AfterBeanDiscoveryImpl.<wbr>finish(AfterBeanDiscoveryImpl.<wbr>java:180)<br>
&gt; &gt;&gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt; Problem????<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.AfterBeanDiscoveryImpl.<wbr>fire(AfterBeanDiscoveryImpl.<wbr>java:76)<br>
&gt; &gt;&gt; at org.jboss.weld.bootstrap.<wbr>WeldStartup.deployBeans(<wbr>WeldStartup.java:446)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>WeldBootstrap.deployBeans(<wbr>WeldBootstrap.java:83)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.cdi.impl.<wbr>CDIContainerImpl.<wbr>startInitialization(<wbr>CDIContainerImpl.java:149)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.cdi.liberty.<wbr>CDIRuntimeImpl.<wbr>applicationStarting(<wbr>CDIRuntimeImpl.java:400)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.container.service.<wbr>state.internal.<wbr>ApplicationStateManager.<wbr>fireStarting(<wbr>ApplicationStateManager.java:<wbr>28)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.container.service.<wbr>state.internal.<wbr>StateChangeServiceImpl.<wbr>fireApplicationStarting(<wbr>StateChangeServiceImpl.java:<wbr>50)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.app.manager.module.<wbr>internal.DeployedAppInfoBase.<wbr>preDeployApp(<wbr>DeployedAppInfoBase.java:383)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.app.manager.module.<wbr>internal.DeployedAppInfoBase.<wbr>deployApp(DeployedAppInfoBase.<wbr>java:412)<br>
&gt; &gt;&gt; at <a href="http://com.ibm.ws.app.manager.war.int" rel="noreferrer" target="_blank">com.ibm.ws.app.manager.war.int</a><br>
&gt; &gt;&gt; ernal.<wbr>WARApplicationHandlerImpl.<wbr>install(<wbr>WARApplicationHandlerImpl.<wbr>java:65)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.app.manager.<wbr>internal.statemachine.<wbr>StartAction.execute(<wbr>StartAction.java:140)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.app.manager.<wbr>internal.statemachine.<wbr>ApplicationStateMachineImpl.<wbr>enterState(<wbr>ApplicationStateMachineImpl.<wbr>java:1258)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; com.ibm.ws.app.manager.<wbr>internal.statemachine.<wbr>ApplicationStateMachineImpl.<wbr>run(<wbr>ApplicationStateMachineImpl.<wbr>java:873)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; java.util.concurrent.<wbr>ThreadPoolExecutor.runWorker(<wbr>ThreadPoolExecutor.java:1149)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; java.util.concurrent.<wbr>ThreadPoolExecutor$Worker.run(<wbr>ThreadPoolExecutor.java:624)<br>
&gt; &gt;&gt; at java.lang.Thread.run(Thread.<wbr>java:748)<br>
&gt; &gt;&gt; Caused by: org.jboss.weld.exceptions.<wbr>DeploymentException: WELD-000179:<br>
&gt; &gt;&gt; ObserverMethodConfigurator created by<br>
&gt; &gt;&gt; org.jboss.cdi.tck.tests.<wbr>extensions.lifecycle.broken.<wbr>observerMethod.<wbr>AfterBeanDiscoveryObserver@<wbr>d31423c<br>
&gt; &gt;&gt; cannot be processed<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.AfterBeanDiscoveryImpl$<wbr>ObserverRegistration.<wbr>initObserverMethod(<wbr>AfterBeanDiscoveryImpl.java:<wbr>368)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.AfterBeanDiscoveryImpl.<wbr>processObserverRegistration(<wbr>AfterBeanDiscoveryImpl.java:<wbr>268)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.AfterBeanDiscoveryImpl.<wbr>finish(AfterBeanDiscoveryImpl.<wbr>java:177)<br>
&gt; &gt;&gt; ... 16 more<br>
&gt; &gt;&gt; Caused by: org.jboss.weld.exceptions.<wbr>DefinitionException: WELD-000415:<br>
&gt; &gt;&gt; Custom<br>
&gt; &gt;&gt; implementation of observer method does not override either notify(T) or<br>
&gt; &gt;&gt; notify(EventContext&lt;T&gt;):<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.configurator.<wbr>ObserverMethodConfiguratorImpl<wbr>@7e164c01<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.configurator.<wbr>ObserverMethodConfiguratorImpl<wbr>$ImmutableObserverMethod.&lt;<wbr>init&gt;(<wbr>ObserverMethodConfiguratorImpl<wbr>.java:272)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.configurator.<wbr>ObserverMethodConfiguratorImpl<wbr>.complete(<wbr>ObserverMethodConfiguratorImpl<wbr>.java:234)<br>
&gt; &gt;&gt; at<br>
&gt; &gt;&gt; org.jboss.weld.bootstrap.<wbr>events.AfterBeanDiscoveryImpl$<wbr>ObserverRegistration.<wbr>initObserverMethod(<wbr>AfterBeanDiscoveryImpl.java:<wbr>366)<br>
&gt; &gt;&gt; ... 18 more<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; We can see the AfterBeanDiscoveryImpl.java:<wbr>180 being<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; /**<br>
&gt; &gt;&gt; * Bean and observer registration is delayed until after all {@link<br>
&gt; &gt;&gt; AfterBeanDiscovery} observers are notified.<br>
&gt; &gt;&gt; */<br>
&gt; &gt;&gt; private void finish() {<br>
&gt; &gt;&gt; try {<br>
&gt; &gt;&gt; GlobalEnablementBuilder globalEnablementBuilder =<br>
&gt; &gt;&gt; getBeanManager().getServices()<wbr>.get(GlobalEnablementBuilder.<wbr>class);<br>
&gt; &gt;&gt; for (BeanRegistration registration : additionalBeans) {<br>
&gt; &gt;&gt; processBeanRegistration(<wbr>registration, globalEnablementBuilder);<br>
&gt; &gt;&gt; }<br>
&gt; &gt;&gt; for (ObserverRegistration registration : additionalObservers) {<br>
&gt; &gt;&gt; processObserverRegistration(<wbr>registration);<br>
&gt; &gt;&gt; }<br>
&gt; &gt;&gt; } catch (Exception e) {<br>
&gt; &gt;&gt; throw new DefinitionException(e); &lt;&lt;&lt;&lt;&lt;&lt; line 180<br>
&gt; &gt;&gt; }<br>
&gt; &gt;&gt; }<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I am also aware of, in <a href="http://docs.jboss.org/cdi/spec/2.0/cdi-spec.pdf" rel="noreferrer" target="_blank">http://docs.jboss.org/cdi/<wbr>spec/2.0/cdi-spec.pdf</a><br>
&gt; &gt;&gt; 11.5.3.,<br>
&gt; &gt;&gt; &quot;If any observer method of the AfterBeanDiscovery event throws an<br>
&gt; &gt;&gt; exception,<br>
&gt; &gt;&gt; the exception is treated as a definition error by the container&quot;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; So why is the test expecting DeploymentException<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; import <a href="http://javax.enterprise.inject.spi.De" rel="noreferrer" target="_blank">javax.enterprise.inject.spi.De</a> ploymentException;<br>
&gt; &gt;&gt; ... @ShouldThrowException(<wbr>DeploymentException.class)<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; It seems like the test is seeing<br>
&gt; &gt;&gt; @SpecAssertions({ @SpecAssertion(section = AFTER_BEAN_DISCOVERY, id =<br>
&gt; &gt;&gt; &quot;ee&quot;)<br>
&gt; &gt;&gt; })<br>
&gt; &gt;&gt; If the container is unable to process the ObserverMethodConfigurator it<br>
&gt; &gt;&gt; automatically detects the problem and treats it as a deployment problem.<br>
&gt; &gt;&gt; as dominant but the weld implementation is seeing<br>
&gt; &gt;&gt; <a href="http://docs.jboss.org/cdi/spec/2.0/cdi-spec.pdf" rel="noreferrer" target="_blank">http://docs.jboss.org/cdi/<wbr>spec/2.0/cdi-spec.pdf</a> : 11.5.3<br>
&gt; &gt;&gt; If any observer method of the AfterBeanDiscovery event throws an<br>
&gt; &gt;&gt; exception,<br>
&gt; &gt;&gt; the exception is treated as a definition error by the container&quot;<br>
&gt; &gt;&gt; as dominant.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; ....and the two do not agree.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; So the bottom line is the CDI CTS/TCK test<br>
&gt; &gt;&gt; org.jboss.cdi.tck.tests.<wbr>extensions.lifecycle.broken.<wbr>observerMethod.<wbr>ObserverMethodWithoutNotifyMet<wbr>hodTest<br>
&gt; &gt;&gt; fails due to the inconsistency.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Have I missunderstood the spec contradiction or missed some part of Weld<br>
&gt; &gt;&gt; integration needed?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Gordon Hutchison<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; ______________________________<wbr>_________________<br>
&gt; &gt;&gt; weld-dev mailing list<br>
&gt; &gt;&gt; <a href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a><br>
&gt; &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/weld-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/weld-dev</a><br>
&gt; &gt; ______________________________<wbr>_________________<br>
&gt; &gt; weld-dev mailing list<br>
&gt; &gt; <a href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a><br>
&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/weld-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/weld-dev</a><br>
&gt; &gt; <br>
&gt; <br>
&gt; --<br>
&gt; Martin Kouba<br>
&gt; Senior Software Engineer<br>
&gt; Red Hat, Czech Republic<br>
&gt; <br>
</div></div></blockquote></div><br></div>