2 Replies Latest reply on Jan 3, 2012 2:30 AM by Damon Chong

    Custom MessageDriven Bean causing shutdown error

    Damon Chong Newbie

      I am encountering this error below with SEAM v2.2.0. This is during JBoss (v5.1.0) shutdown only if my MDB (annotated with @MessageDriven) had been activated.



      14:50:00,353 WARN  [Component] Exception calling component @Destroy method: org.jboss.seam.jms.queueConnection
      java.lang.RuntimeException: exception invoking: destroy
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:154)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
           at org.jboss.seam.Component.callDestroyMethod(Component.java:2180)
           at org.jboss.seam.Component.destroy(Component.java:1469)
           at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:251)
           at org.jboss.seam.contexts.Lifecycle.endApplication(Lifecycle.java:61)
           at org.jboss.seam.contexts.ServletLifecycle.endApplication(ServletLifecycle.java:149)
           at org.jboss.seam.servlet.SeamListener.contextDestroyed(SeamListener.java:41)
           at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3949)
           at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4615)
           at org.apache.catalina.core.ContainerBase.destroy(ContainerBase.java:1175)
           at org.apache.catalina.core.StandardContext.destroy(StandardContext.java:4705)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
           at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
           at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performUndeployInternal(TomcatDeployment.java:596)
           at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performUndeploy(TomcatDeployment.java:570)
           at org.jboss.web.deployers.AbstractWarDeployment.stop(AbstractWarDeployment.java:480)
           at org.jboss.web.deployers.WebModule.stopModule(WebModule.java:133)
           at org.jboss.web.deployers.WebModule.stop(WebModule.java:102)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
           at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
           at $Proxy38.stop(Unknown Source)
           at org.jboss.system.microcontainer.StartStopLifecycleAction.uninstallAction(StartStopLifecycleAction.java:56)
           at org.jboss.system.microcontainer.StartStopLifecycleAction.uninstallAction(StartStopLifecycleAction.java:37)
           at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleUninstallAction(SimpleControllerContextAction.java:79)
           at org.jboss.dependency.plugins.action.AccessControllerContextAction.uninstall(AccessControllerContextAction.java:131)
           at org.jboss.dependency.plugins.AbstractControllerContextActions.uninstall(AbstractControllerContextActions.java:58)
           at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:354)
           at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:1664)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1275)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1179)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1234)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:827)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
           at org.jboss.system.ServiceController.stop(ServiceController.java:510)
           at org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback.uninstall(ServiceControllerStartStopLifecycleCallback.java:52)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
           at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
           at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
           at org.jboss.beans.info.plugins.AbstractBeanInfo.invoke(AbstractBeanInfo.java:300)
           at org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext.invoke(AbstractKernelControllerContext.java:286)
           at org.jboss.dependency.plugins.AbstractLifecycleCallbackItem.uninstall(AbstractLifecycleCallbackItem.java:112)
           at org.jboss.dependency.plugins.AbstractController.handleLifecycleCallbacks(AbstractController.java:1570)
           at org.jboss.dependency.plugins.AbstractController.handleUninstallLifecycleCallbacks(AbstractController.java:1546)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1273)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1179)
           at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:655)
           at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:568)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.undeploy(BeanMetaDataDeployer.java:153)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.undeploy(BeanMetaDataDeployer.java:51)
           at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalUndeploy(AbstractSimpleRealDeployer.java:69)
           at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.undeploy(AbstractRealDeployer.java:112)
           at org.jboss.deployers.plugins.deployers.DeployerWrapper.undeploy(DeployerWrapper.java:196)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doUndeploy(DeployersImpl.java:1469)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1376)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doUninstallParentLast(DeployersImpl.java:1369)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.uninstall(DeployersImpl.java:1331)
           at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:354)
           at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:1664)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1275)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:827)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:694)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679)
           at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
           at org.jboss.system.server.profileservice.repository.ProfileDeployAction.uninstall(ProfileDeployAction.java:95)
           at org.jboss.system.server.profileservice.repository.AbstractProfileAction.uninstall(AbstractProfileAction.java:70)
           at org.jboss.system.server.profileservice.repository.AbstractProfileService.uninstall(AbstractProfileService.java:375)
           at org.jboss.dependency.plugins.AbstractControllerContext.uninstall(AbstractControllerContext.java:354)
           at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:1664)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1275)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1179)
           at org.jboss.dependency.plugins.AbstractController.uninstallContext(AbstractController.java:1234)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:827)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.system.server.profileservice.repository.AbstractProfileService.deactivateProfile(AbstractProfileService.java:402)
           at org.jboss.system.server.profileservice.ProfileServiceBootstrap.deactivateProfiles(ProfileServiceBootstrap.java:388)
           at org.jboss.system.server.profileservice.ProfileServiceBootstrap.shutdown(ProfileServiceBootstrap.java:345)
           at org.jboss.bootstrap.AbstractServerImpl.shutdownServer(AbstractServerImpl.java:571)
           at org.jboss.bootstrap.AbstractServerImpl$ShutdownHook.run(AbstractServerImpl.java:909)
      Caused by: javax.jms.IllegalStateException: Transaction not active
           at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.checkTransactionActive(JmsSessionFactoryImpl.java:456)
           at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.checkClosed(JmsSessionFactoryImpl.java:437)
           at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.stop(JmsSessionFactoryImpl.java:253)
           at org.jboss.seam.jms.QueueConnection.destroy(QueueConnection.java:58)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           ... 97 more
      Caused by: java.lang.IllegalStateException: No transaction manager: jboss.jca:service=CachedConnectionManager
           at org.jboss.resource.connectionmanager.TxConnectionManager.checkTransactionActive(TxConnectionManager.java:325)
           at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.checkTransactionActive(BaseConnectionManager2.java:972)
           at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.checkTransactionActive(JmsSessionFactoryImpl.java:452)
           ... 106 more
      14:50:00,353 INFO  [StandardService] Stopping service jboss.web



      This is my MDB class as below



      @Name("jms_longRunJobManager")
      @MessageDriven(name="jms_longRunJobManager", activationConfig= {
                @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
                @ActivationConfigProperty(propertyName="destination", propertyValue="/queue/merAppsLongRunningJobs"),
                @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
                @ActivationConfigProperty(propertyName = "dLQMaxResent", propertyValue = "0")
      })
      public class LongRunJobManager implements MessageListener {
      
           @Logger 
           private Log log;
           @PersistenceContext
           EntityManager em;
           
           @Override
           public void onMessage(Message msg) {
                Session session = null;
                TextMessage textMsg = (TextMessage)msg;
                try {
                     log.debug("Received: {0}", textMsg.getText());
                     session = (Session)em.getDelegate();
                     Transaction trans = session.beginTransaction();
      
                     Query query = session.createSQLQuery("SELECT count(1) from sample");
                     int size = ((Integer)query.list().iterator().next()).intValue();
                     log.info("Size of sample table: {0}", size);
                     session.flush();               
                     trans.commit();
                } catch (Exception e) {               
                     try{
                    if( null!=session && session.getTransaction().isActive() ){
                         session.getTransaction().rollback();
                    }
                     }
                     catch( Exception e1 ){
                          e1.printStackTrace();
                     }
                     
                     throw new EJBException(e);
                }
           }
      
      }



      And my JMS service declaration file, merAppsLRJ-jms-destination-service.xml placed in JBoss default deploy folder.



      <?xml version="1.0" encoding="UTF-8"?>
      <server>
         <mbean code="org.jboss.jms.server.destination.QueueService"
           name="jboss.messaging.destination:service=Queue,name=merAppsLongRunningJobs"
           xmbean-dd="xmdesc/Queue-xmbean.xml">
            <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
            <depends>jboss.messaging:service=PostOffice</depends>
         </mbean>
      </server>



      It appears that the container had earlier called TxConnectionManager's stopService() method and during shutdown, the @Destroy method of the SEAM component, org.jboss.seam.jms.queueConnection was called which encountered a null TransactionManager object in the component.


      I try to do a workaround by modifying the jca-jboss-beans.xml file value for the CachedConnectionManager bean to false as below:


      <!-- Whether to track unclosed connections and close them -->
           <property name="debug">false</property>



      but no cigar. Not sure if this is an issue involving interaction between JBOSS and SEAM. Anyone encounter anything issue? Any help appreciated very much. I really hate to have this error msg during JBoss shutdown in a production env. Thank you!

        • 1. Re: Custom MessageDriven Bean causing shutdown error
          Damon Chong Newbie

          Additional information, I am putting the message in the queue from a conversation scoped seam component using @Transactional annotation in the method. Briefly, the code is as below:


                         queueSender.send(queueSession.createTextMessage("Seam ROCKS!"));               
                      queueSender.close();
                      queueSession.close();



          The QueueSession and QueueSender are injected as below:


          @In("merAppsLRJQueueSender")
          private QueueSender queueSender; 
          @In(create = true)
          private QueueSession queueSession;



          I traced the shutdown process. It seems like JBoss will call the stopService() method in TxConnectionManager for the default JMS resource and this was followed subsequently by SEAM's QueueConnection calling javax.jms.QueueConnection's stop() method which will then again call the JBoss's JmsSessionFactoryImpl's stop() method which by now already has a null variable for its TransactionManager object due to earlier stopService() call.


          So again I am not sure if this is an issue arising from SEAM/JBoss interaction altho one would think SEAM should not be calling a JMS implementation that had been removed by the J2EE container. Hope my understanding is correct and it's not my code implementation fault. Thank you again for your attention!

          • 2. Re: Custom MessageDriven Bean causing shutdown error
            Damon Chong Newbie

            Looking at the source code in SEAM v2.2.2 for org.jboss.seam.jms.QueueConnection's destroy() method, the IllegalStateException would be treated as a warning instead. However, I feel that if the TransactionManager instance is no longer available, SEAM should not attempt to stop the queue connection. Unfortunately, looks like there is no way to interrogate the QueueConnection to see if this is the case. So case closed, guess we just have to update to SEAM v2.2.2 from v2.2.0. Cheers.