1 Reply Latest reply on Jan 30, 2012 6:26 AM by Maas van den Berg

    EJBs prematurely stopped upon undeploy(?)

    Maas van den Berg Newbie

      EJBs calls during application shutdown fail because the EJBs are stopped before web components or CDI components are.

       

      For example the following used to work in 6.1.0 and 7.0.1

       

      {code}

      @WebListener

      public class App implements ServletContextListener {

        @EJB

        private Bean bean;

       

       

        @Override

        public void contextInitialized(ServletContextEvent sce) {

          System.out.println("App.contextInitialized");

          bean.registerStartup();

        }

       

       

        @Override

        public void contextDestroyed(ServletContextEvent sce) {

          System.out.println("App.contextDestroyed");

          bean.registerShutdown();

        }

      }

      {code}

       

      But on 7.1.0-SNAPSHOT it results in

       

      {quote}

      10:16:04,548 INFO  stdout (MSC service thread 1-3) App.contextDestroyed

      10:16:04,566 ERROR [org.jboss.ejb3.invocation] (MSC service thread 1-3) JBAS014134: EJB Invocation failed on component Bean for method public void stoptest.Bean.registerShutdown(): javax.ejb.EJBException: java.lang.IllegalStateException: JBAS011049: Component is stopped

           at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at stoptest.Bean$$$view2.registerShutdown(Unknown Source) [classes:]

           at stoptest.App.contextDestroyed(App.java:22) [classes:]

           at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3489) [jbossweb-7.0.9.Final.jar:]

           at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3999) [jbossweb-7.0.9.Final.jar:]

           at org.jboss.as.web.deployment.WebDeploymentService.stop(WebDeploymentService.java:96) [jboss-as-web-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.msc.service.ServiceControllerImpl$StopTask.stopService(ServiceControllerImpl.java:1909)

           at org.jboss.msc.service.ServiceControllerImpl$StopTask.run(ServiceControllerImpl.java:1872)

           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_29]

           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_29]

           at java.lang.Thread.run(Thread.java:680) [:1.6.0_29]

      Caused by: java.lang.IllegalStateException: JBAS011049: Component is stopped

           at org.jboss.as.ee.component.BasicComponent.waitForComponentStart(BasicComponent.java:104) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:127) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:85) [jboss-as-ee-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:65) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:62) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.pool.AbstractPool.create(AbstractPool.java:60) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:128) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:47) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

           at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]

           ... 27 more

      {quote}