0 Replies Latest reply on Jun 11, 2013 3:16 PM by Chris Stillwell

    How do you set a shutdown hook for jboss when @PreDestroy is too late?

    Chris Stillwell Newbie

      We have some service cleanup that needs to be performed when JBoss shutsdown.  We had implemented a @Singleton bean with a @PreDestroy method to handle this cleanup, but it appears that this is too late in the shut down process.

       

      We're trying to unbind some components from JNDI and make a call to a remote EJB.

       

      Unbind fails with:

       

      Caused by: javax.naming.NamingException: JBAS011836: Could not resolve service service jboss.naming.context.java.xxi.modules.BttbTaskWorkerModule

              at org.jboss.as.naming.WritableServiceBasedNamingStore.unbind(WritableServiceBasedNamingStore.java:121)

              at org.jboss.as.naming.WritableServiceBasedNamingStore.unbind(WritableServiceBasedNamingStore.java:112)

              at org.jboss.as.naming.NamingContext.unbind(NamingContext.java:286)

              at org.jboss.as.naming.NamingContext.unbind(NamingContext.java:294)

              at com.xxi.framework.moduleservice.bind.AbstractBindCallback.unbind(AbstractBindCallback.java:185) [xxi-framework-module-service-common-6.0.10-SNAPSHOT.jar:]

              ... 36 more

       

      We also try to issue a remote EJB call and get this:

       

      Caused by: java.lang.IllegalArgumentException: JBAS011857: NamingStore is null

              at org.jboss.as.naming.NamingContext.<init>(NamingContext.java:152) [jboss-as-naming-7.2.0.Final.jar:7.2.0.Final]

              at org.jboss.as.naming.NamingContext.<init>(NamingContext.java:125) [jboss-as-naming-7.2.0.Final.jar:7.2.0.Final]

              at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:86) [jboss-as-naming-7.2.0.Final.jar:7.2.0.Final]

              at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:44) [jboss-as-naming-7.2.0.Final.jar:7.2.0.Final]

              at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) [rt.jar:1.7.0_15]

              at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) [rt.jar:1.7.0_15]

              at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:335) [rt.jar:1.7.0_15]

              at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_15]

              at com.xxi.framework.moduleproxy.JBoss7SynchronousProxy.setupEJB(JBoss7SynchronousProxy.java:226)

              at com.xxi.framework.moduleproxy.JBoss7SynchronousProxy.doInvoke(JBoss7SynchronousProxy.java:318)

              at com.xxi.framework.moduleproxy.JBoss7SynchronousProxy.invoke(JBoss7SynchronousProxy.java:268)

              at com.sun.proxy.$Proxy74.removeFeedUser(Unknown Source)

              at com.farecompare.bttb.feedusercomponent.impl.BttbFeedUserComponentImpl.shutdown(BttbFeedUserComponentImpl.java:292)

              at com.farecompare.bttb.workermodule.impl.BttbWorkerModule.shutdownComponent(BttbWorkerModule.java:161)

              at com.farecompare.bttb.workermodule.impl.BttbWorkerWithLifeCycleModule.shutdown(BttbWorkerWithLifeCycleModule.java:87)

              at com.xxi.framework.moduleservice.ModuleLoader.unbind(ModuleLoader.java:355)

              at com.xxi.framework.moduleservice.ModuleLoaderService.shutdown(ModuleLoaderService.java:136)

              at com.xxi.framework.moduleservice.JBossModuleService.stopService(JBossModuleService.java:97

       

      This sounds the same as:

      https://community.jboss.org/thread/196856

       

      It reccomends using @DependsOn, but what would I depend on to ensure the NamingStore has not already been destroyed?

       

      Or is this to be fixed in a later release?  https://issues.jboss.org/browse/WFLY-1247