CDI BeforeShutdown method in JBoss module fails because HornetQ gets shutdown first

Solution In Progress - Updated -

Issue

I am using CDI in a JBoss Module and at shut down I need to look up the HornetQ
but HornetQ is shutdown before this can be called. This results in an exception being thrown:

11:55:38,767 ERROR [org.jboss.weld.Bootstrap] (MSC service thread 1-3) : java.lang.IllegalArgumentException: javax.naming.NameNotFoundException: JmsXA -- service jboss.naming.context.java.JmsXA
at com.aaa.bbb.redhatreproducer.module.LookupUtil.lookup(LookupUtil.java:17) [redhat-reproducer-module-0.0.1.jar:]
at com.aaa.bbb.redhatreproducer.module.ExtesionLookingUpJmsConnectionFactory.lookupConnectionFactory(ExtesionLookingUpJmsConnectionFactory.java:31) [redhat-reproducer-module-0.0.1.jar:]
at com.aaa.bbb.redhatreproducer.module.ExtesionLookingUpJmsConnectionFactory.beforeShutdown(ExtesionLookingUpJmsConnectionFactory.java:26) [redhat-reproducer-module-0.0.1.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_71]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_71]
at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:45) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at com.aaa.bbb.redhatreproducer.module.ExtesionLookingUpJmsConnectionFactory$Proxy$$$_WeldClientProxy.beforeShutdown(ExtesionLookingUpJmsConnectionFactory$Proxy$$$_WeldClientProxy.java) [redhat-reproducer-module-0.0.1.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_71]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_71]
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:164) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:163) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:245) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:233) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:213) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:75) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.bootstrap.events.BeforeShutdownImpl.fire(BeforeShutdownImpl.java:53) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.bootstrap.events.BeforeShutdownImpl.fire(BeforeShutdownImpl.java:43) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:461) [weld-core-1.1.31.Final-redhat-1.jar:1.1.31.Final-redhat-1]
at org.jboss.as.weld.WeldStartService.stop(WeldStartService.java:96) [jboss-as-weld-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at org.jboss.msc.service.ServiceControllerImpl$StopTask.stopService(ServiceControllerImpl.java:2088)
at org.jboss.msc.service.ServiceControllerImpl$StopTask.run(ServiceControllerImpl.java:2049)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_71]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_71]
Caused by: javax.naming.NameNotFoundException: JmsXA -- service jboss.naming.context.java.JmsXA
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104) [jboss-as-naming-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197) [jboss-as-naming-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:243) [jboss-as-naming-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183) [jboss-as-naming-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179) [jboss-as-naming-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_71]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_71]
at com.aaa.bbb.redhatreproducer.module.LookupUtil.lookup(LookupUtil.java:15) [redhat-reproducer-module-0.0.1.jar:]
... 33 more

How do I stop this?

Environment

Red Hat JBoss Enterprise Application Platform 6.4.5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content