<div dir="ltr"><div>Hi Folks, <br><br>I work in the IBM CDI implementation team. <br><br>We are running the CDI 2.0 TCK/CDS and get a test failure on: <br><br>org.jboss.cdi.tck.tests.extens<wbr>ions.lifecycle.broken.observer<wbr>Method.ObserverMethodWithoutNo<wbr>tifyMethodTest <br><br>that I need some advice on. <br><br>The test has: <br><br>import <a href="http://javax.enterprise.inject.spi.De">javax.enterprise.inject.spi.De</a><wbr>ploymentException; <br> <br> @ShouldThrowException(Deployme<wbr>ntException.class) <br><br><br> // unable to process ObserverMethodConfigurator due to missing notify method impl <br> @Test <br> @SpecAssertions({ @SpecAssertion(section = AFTER_BEAN_DISCOVERY, id = "ee") }) <br> public void unableToProcessObserverMethodC<wbr>onfigurator() { <br> } <br><br>This behaviour is specified in <br> <a href="https://docs.jboss.org/cdi/spec/2.0/cdi-spec-with-assertions.html#after_bean_discovery" target="_blank">https://docs.jboss.org/cdi/spe<wbr>c/2.0/cdi-spec-with-assertions<wbr>.html#after_bean_discovery</a> <br>(search for "ee)" ) <br><br>ee)
If the container is unable to process the ObserverMethodConfigurator it
automatically detects the problem and treats it as a deployment
problem. <br>ObserverMethodWithoutNotifyMet<wbr>hodTest.unableToProcessObserve<wbr>rMethodConfigurator()<br><br><br>However
what we see coming back from Weld is not a javax DeploymentException
but a javax DefinitionException wrapping a weld DeploymentException
cause <br><br>Stack Dump = <a href="http://javax.enterprise.inject.spi.De">javax.enterprise.inject.spi.De</a><wbr>finitionException: org.jboss.weld.exceptions.Depl<wbr>oymentException: WELD-000179: ObserverMethodConfigurator created by org.jboss.cdi.tck.tests.extens<wbr>ions.lifecycle.broken.observer<wbr>Method.AfterBeanDiscoveryObser<wbr>ver@d31423c cannot be processed <br> at org.jboss.weld.bootstrap.event<wbr>s.AfterBeanDiscoveryImpl.finis<wbr>h(AfterBeanDiscoveryImpl.java:<wbr>180) <wbr> <<<<<<< Problem???? <br> at org.jboss.weld.bootstrap.event<wbr>s.AfterBeanDiscoveryImpl.fire(<wbr>AfterBeanDiscoveryImpl.java:<wbr>76) <br> at org.jboss.weld.bootstrap.WeldS<wbr>tartup.deployBeans(WeldStartup<wbr>.java:446) <br> at org.jboss.weld.bootstrap.WeldB<wbr>ootstrap.deployBeans(WeldBoots<wbr>trap.java:83) <br> at com.ibm.ws.cdi.impl.CDIContain<wbr>erImpl.startInitialization(CDI<wbr>ContainerImpl.java:149) <br> at com.ibm.ws.cdi.liberty.CDIRunt<wbr>imeImpl.applicationStarting(CD<wbr>IRuntimeImpl.java:400) <br> at com.ibm.ws.container.service.s<wbr>tate.internal.ApplicationState<wbr>Manager.fireStarting(Applicati<wbr>onStateManager.java:28) <br> at com.ibm.ws.container.service.s<wbr>tate.internal.StateChangeServi<wbr>ceImpl.fireApplicationStarting<wbr>(StateChangeServiceImpl.java:5<wbr>0) <br> at com.ibm.ws.app.manager.module.<wbr>internal.DeployedAppInfoBase.p<wbr>reDeployApp(DeployedAppInfoBas<wbr>e.java:383) <br> at com.ibm.ws.app.manager.module.<wbr>internal.DeployedAppInfoBase.d<wbr>eployApp(DeployedAppInfoBase.j<wbr>ava:412) <br> at <a href="http://com.ibm.ws.app.manager.war.int">com.ibm.ws.app.manager.war.int</a><wbr>ernal.WARApplicationHandlerImp<wbr>l.install(WARApplicationHandle<wbr>rImpl.java:65) <br> at com.ibm.ws.app.manager.interna<wbr>l.statemachine.StartAction.<wbr>execute(StartAction.java:140) <br> at com.ibm.ws.app.manager.interna<wbr>l.statemachine.ApplicationStat<wbr>eMachineImpl.enterState(Applic<wbr>ationStateMachineImpl.java:<wbr>1258) <br> at com.ibm.ws.app.manager.interna<wbr>l.statemachine.ApplicationStat<wbr>eMachineImpl.run(ApplicationSt<wbr>ateMachineImpl.java:873) <br> at java.util.concurrent.ThreadPoo<wbr>lExecutor.runWorker(ThreadPool<wbr>Executor.java:1149) <br> at java.util.concurrent.ThreadPoo<wbr>lExecutor$Worker.run(ThreadPoo<wbr>lExecutor.java:624) <br> at java.lang.Thread.run(Thread.ja<wbr>va:748) <br>Caused by: org.jboss.weld.exceptions.Depl<wbr>oymentException: WELD-000179: ObserverMethodConfigurator created by org.jboss.cdi.tck.tests.extens<wbr>ions.lifecycle.broken.observer<wbr>Method.AfterBeanDiscoveryObser<wbr>ver@d31423c cannot be processed <br> at org.jboss.weld.bootstrap.event<wbr>s.AfterBeanDiscoveryImpl$Obser<wbr>verRegistration.initObserverMe<wbr>thod(AfterBeanDiscoveryImpl.<wbr>java:368) <br> at org.jboss.weld.bootstrap.event<wbr>s.AfterBeanDiscoveryImpl.proce<wbr>ssObserverRegistration(AfterBe<wbr>anDiscoveryImpl.java:268) <br> at org.jboss.weld.bootstrap.event<wbr>s.AfterBeanDiscoveryImpl.finis<wbr>h(AfterBeanDiscoveryImpl.java:<wbr>177) <br> ... 16 more <br>Caused by: org.jboss.weld.exceptions.Defi<wbr>nitionException:
WELD-000415: Custom implementation of observer method does not override
either notify(T) or notify(EventContext<T>):
org.jboss.weld.bootstrap.event<wbr>s.configurator.ObserverMethodC<wbr>onfiguratorImpl@7e164c01 <br> at org.jboss.weld.bootstrap.event<wbr>s.configurator.ObserverMethodC<wbr>onfiguratorImpl$<wbr>ImmutableObserverMethod.<init><wbr>(ObserverMethodConfiguratorImp<wbr>l.java:272) <br> at org.jboss.weld.bootstrap.event<wbr>s.configurator.ObserverMethodC<wbr>onfiguratorImpl.complete(Obser<wbr>verMethodConfiguratorImpl.<wbr>java:234) <br> at org.jboss.weld.bootstrap.event<wbr>s.AfterBeanDiscoveryImpl$Obser<wbr>verRegistration.initObserverMe<wbr>thod(AfterBeanDiscoveryImpl.<wbr>java:366) <br> ... 18 more <br><br><br>We can see the AfterBeanDiscoveryImpl.java:18<wbr>0 being <br><br> /** <br> * Bean and observer registration is delayed until after all {@link AfterBeanDiscovery} observers are notified. <br> */ <br> private void finish() { <br> try { <br> GlobalEnablementBuilder globalEnablementBuilder = getBeanManager().getServices()<wbr>.get(GlobalEnablementBuilder.c<wbr>lass); <br> for (BeanRegistration registration : additionalBeans) { <br> processBeanRegistration(regist<wbr>ration, globalEnablementBuilder); <br> } <br> for (ObserverRegistration registration : additionalObservers) { <br> processObserverRegistration(re<wbr>gistration); <br> } <br> } catch (Exception e) { <br> throw new DefinitionException(e); <<<<<< line 180 <br> } <br> } <br><br><br>I am also aware of, in <a href="http://docs.jboss.org/cdi/spec/2.0/cdi-spec.pdf" target="_blank">http://docs.jboss.org/cdi/spec<wbr>/2.0/cdi-spec.pdf</a> 11.5.3., <br>
"If any observer method of the AfterBeanDiscovery event throws an
exception, the exception is treated as a definition error by the
container" <br><br>So why is the test expecting DeploymentException <br><br>import <a href="http://javax.enterprise.inject.spi.De">javax.enterprise.inject.spi.De</a><wbr>ploymentException; <br>... @ShouldThrowException(Deployme<wbr>ntException.class) <br><br><br>It seems like the test is seeing <br> @SpecAssertions({ @SpecAssertion(section = AFTER_BEAN_DISCOVERY, id = "ee") }) <br>
If the container is unable to process the ObserverMethodConfigurator it
automatically detects the problem and treats it as a deployment
problem. <br>as dominant but the weld implementation is seeing <br> <a href="http://docs.jboss.org/cdi/spec/2.0/cdi-spec.pdf" target="_blank">http://docs.jboss.org/cdi/spec<wbr>/2.0/cdi-spec.pdf</a>: 11.5.3 <br>
If any observer method of the AfterBeanDiscovery event throws an
exception, the exception is treated as a definition error by the
container" <br>as dominant. <br><br>....and the two do not agree. <br><br>So the bottom line is the CDI CTS/TCK test <br> org.jboss.cdi.tck.tests.extens<wbr>ions.lifecycle.broken.observer<wbr>Method.ObserverMethodWithoutNo<wbr>tifyMethodTest <br>fails due to the inconsistency. <br><br>Have I missunderstood the spec contradiction or missed some part of Weld integration needed? <br><br></div>Gordon Hutchison<br></div>