holixon / axon-cdi

CDI Extension to use AxonFramework 3.x in Container Environments
Apache License 2.0
4 stars 1 forks source link

Fix Wildfly example #11

Closed zambrovski closed 6 years ago

zambrovski commented 6 years ago
16:36:16,762 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 13) MSC000001: Failed to start service jboss.deployment.unit."wildfly.war".component.CdiApplication.START: org.jboss.msc.service.StartException in service jboss.deployment.unit."wildf
ly.war".component.CdiApplication.START: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
        at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:57)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
        at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
        at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
        at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)
        at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:124)
        at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:138)
        at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)
        ... 6 more
Caused by: javax.ejb.EJBException: org.axonframework.commandhandling.NoHandlerForCommandException: No handler was subscribed to command [org.axonframework.extension.example.common.core.api.CreateAccountCommand]
alexmacavei commented 6 years ago

My wildfly-swarm example now fails with:

Exception 0 :
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456: Argument resolvedBean must not be null
        at org.jboss.weld.util.Preconditions.checkArgumentNotNull(Preconditions.java:40)
        at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:810)
        at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
        at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:358)
        at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:369)
        at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:70)
        at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
        at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72)
        at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
        at org.jboss.resteasy.cdi.JaxrsInjectionTarget.inject(JaxrsInjectionTarget.java:44)
        at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
        at org.axonframework.cdi.extension.AxonCdiExtension.lambda$null$7(AxonCdiExtension.java:286)
        at org.axonframework.config.Component.get(Component.java:73)
        at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
        at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
        at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.util.stream.ReferencePipeline.forEach(Unknown Source)
        at org.axonframework.config.EventHandlingConfiguration.initialize(EventHandlingConfiguration.java:412)
        at org.axonframework.config.DefaultConfigurer.lambda$invokeInitHandlers$12(DefaultConfigurer.java:401)
        at java.util.ArrayList.forEach(Unknown Source)
        at org.axonframework.config.DefaultConfigurer.invokeInitHandlers(DefaultConfigurer.java:401)
        at org.axonframework.config.DefaultConfigurer.buildConfiguration(DefaultConfigurer.java:390)
        at org.axonframework.cdi.extension.AxonCdiExtension.afterBeanDiscovery(AxonCdiExtension.java:322)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:88)
        at org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:144)
        at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:299)
        at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:124)
        at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:277)
        at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:255)
        at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:269)
        at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:258)
        at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:154)
        at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:148)
        at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
        at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
        at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:62)
        at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:451)
        at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
        at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:95)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

It seems that when debugging if I evaluate Configuration configuration = configurer.buildConfiguration(); twice, the first time I get the above stack and the second time it works. Only afterwards I bump into the NoHandlerForCommandException... real strange:/

zambrovski commented 6 years ago

I just fixed a small error introduced in my wildfly example (missing beans.xml in commonpackage).

Argument resolvedBean must not be null is strange. It actually says that WELD is not capable to inject null values. Can you debug it so far, to understand what value is null?

I found out that in DeltaSpike example I run in the same error but on a place in code, where no null is injected, but some internals of WELD / Deltaspike behave strange. See #8

alexmacavei commented 6 years ago

Yep will do, it's nice that it's on maven now :D (it's not yet :P) Will update with your changes too first 👍

zambrovski commented 6 years ago

The plan is to pass the entire repository to AxonIQ at some point, so technically, I could release the 0.0.1 but the question is, if it makes any sense now. My plan (discussed with AxonIQ guys) is to pass this poroject to thewm and let them release it... (since it org.axonframework).

alexmacavei commented 6 years ago

Ah alright, I get it :)

alexmacavei commented 6 years ago

Hey I debugged a bit and it seems the error gets thrown when trying to register event handlers in the afterBeanDiscovery method:

// register event handlers
    eventHandlers.forEach(eventHandler -> {
      log.info("Registering event handler {}", eventHandler.getBeanClass().getName());
      eventHandlerConfiguration.registerEventHandler(c -> eventHandler.create(bm.createCreationalContext(null)));
    });

the argument of the eventHandler.create resolves fine but when passing that null creational context to the eventHandler.create the resolvedBean must not be null happens... Should I @Provide something more?

alexmacavei commented 6 years ago

Ok managed to crack it. Was related to JAX-RS injection point, I had my @EventHandler defined in my JAX-RS class. Created a @Named listener like in the example and it's working fine now. Really strange why it wouldn't let me create my eventHandler if it's defined there though... hmm

zambrovski commented 6 years ago

I think you are right with passing null to BeanManager.createCreationalContext() is not correct. For now, I have no idea what to pass there instead of this. I belive this will also fix #8 (actually same error).