2 Replies Latest reply on Oct 6, 2008 7:57 AM by aloubyansky

    Container artifacts should have symmetric lifecycles

    emuckenhuber

      I've started to write some basic tests for ejb container lifecycle,
      based on the cts.tests from the testsuite for:

      https://jira.jboss.org/jira/browse/JBAS-5332

      So basically what i do is:
      - deploy the cts.jar
      - run a cts tests
      - call the serviceController to do a stop/destroy/create/start on the tested bean
      - run the test a 2nd time
      - undeploy the cts.jar

      I do that for the container, then for the cache, the pool.

      This was actually not working for any container. So i've moved some obvious things around,
      which should put that in a better shape.

      Still - after talking to Alexey it seems that it could be a bit more difficult doing the same with CMP.
      At the moment the persistenceManager is created/stopped/destroyed in the entityContainer itself and
      started in the EJBModule. And it seems that it's needed to be started in that way.
      But this makes the bean not usable after restarting just the container - moving this parts into
      the EJBModule seems to work (at least for the simple testcase).

      But i still don't know whether this makes sense or not?

      Most probably we also need to do a bit more testing to make sure that it's really function correctly,
      but at least those tests exposed some problems.

        • 1. Re: Container artifacts should have symmetric lifecycles
          emuckenhuber

          I've commited some test cases and the tests are passing for Session and MessageDriven beans.

          There are two tests still failing regarding to CMP (which are disabled in the normal test runs atm)

          org.jboss.test.ejb.lifecycle.test.CmpLifeCycleUnitTest
          org.jboss.test.ejb.lifecycle.test.UserTransactionLifeCycleUnitTest

          Those tests are failing with this exception:

          Error checking if entity exists:java.sql.SQLException: S1000 General error java.lang.RuntimeException: prepared statement is no longer valid
          javax.ejb.CreateException: Error checking if entity exists:java.sql.SQLException: S1000 General error java.lang.RuntimeException: prepared statement is no longer valid
           at org.jboss.ejb.plugins.cmp.jdbc.JDBCInsertPKCreateCommand.beforeInsert(JDBCInsertPKCreateCommand.java:105)
           at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:150)
           at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:587)
           at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:237)
           at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:223)
           at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:783)
           at org.jboss.invocation.Invocation.performCall(Invocation.java:386)
           at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1130)
           at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:106)
           at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:203)
           at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:187)
           at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:106)
           at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:137)
           at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:76)
           at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:45)
           at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56)
           at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
           at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
           at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
           at org.jboss.ejb.plugins.SecurityInterceptor.process(SecurityInterceptor.java:224)
           at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:199)
           at org.jboss.ejb.plugins.security.PreSecurityInterceptor.process(PreSecurityInterceptor.java:100)
           at org.jboss.ejb.plugins.security.PreSecurityInterceptor.invokeHome(PreSecurityInterceptor.java:88)
           at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
           at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
           at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:525)
           at org.jboss.ejb.Container.invoke(Container.java:1045)
           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.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:232)
           at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:908)
           at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:742)
           at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:695)
           at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:549)
           at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:230)
           at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:206)
           at org.jboss.remoting.Client.invoke(Client.java:1708)
           at org.jboss.remoting.Client.invoke(Client.java:612)
           at org.jboss.invocation.unified.interfaces.UnifiedInvokerProxy.invoke(UnifiedInvokerProxy.java:162)
           at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:244)
           at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:181)
           at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
           at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:87)
           at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)
           at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:101)
          
          


          As mentioned before - moving the code which starts/stops the associated persistenceManager
          to the EjbModule makes those tests pass. I've attached a patch showing those changes to the related JIRA issue.



          • 2. Re: Container artifacts should have symmetric lifecycles
            aloubyansky

            It's complicated with CMP (and maybe EJB in general) since there could be CMR (or other non declared EJB references).
            CMRs aren't translated into service dependencies. So, just restarting an entity bean is not safe. And IMO it shouldn't be a requirement to be able to restart a single container in an EJB module. Instead, the whole EJB module should be restarted since this is what a deployment unit is. Stopping one of the services should stop the whole module.