prblem with using stateless bean in StoreListener

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

prblem with using stateless bean in StoreListener

is_maximum
Hello

in order to track changes and persist them in database I have implemented a StoreListener say StoreListenerImpl and in afterStore() method I lookup an SLSB to persist the changes but at the point of calling its business method for my SB the following exception is thrown. Can anyone help me out please?

Caused by: javax.ejb.EJBTransactionRolledbackException: The transaction has been marked rollback only because the bean encountered a non-application exception :org.apache.openjpa.persistence.InvalidStateException : The context has been closed.  The stack trace at which the context was closed is held in the embedded exception.
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:348)
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:323)
            at org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
            at $Proxy74.save(Unknown Source)
            at com.kishware.core.gl.audit.TrackerImpl.record(TrackerImpl.java:61)
            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:585)
            at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
            at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
            at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:210)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
            at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:321)
            ... 54 more
Caused by:  org.apache.openjpa.persistence.InvalidStateException: The context has been closed.  The stack trace at which the context was closed is held in the embedded exception.
FailedObject: java.lang.IllegalStateException
            at org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4370)
            at org.apache.openjpa.kernel.BrokerImpl.beginOperation(BrokerImpl.java:1766)
            at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2375)
            at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2280)
            at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1021)
            at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:645)
            at com.kishware.common.persistence.dao.ejb.GeneralDataAccessManipulator.doPersist(GeneralDataAccessManipulator.java:128)
            at com.kishware.common.persistence.dao.ejb.GeneralDataAccessManipulator.save(GeneralDataAccessManipulator.java:60)
            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:585)
            at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
            at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
            at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:210)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
            at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:321)
            ... 70 more
Caused by: java.lang.IllegalStateException
            at org.apache.openjpa.kernel.BrokerImpl.free(BrokerImpl.java:4148)
            at org.apache.openjpa.kernel.BrokerImpl.close(BrokerImpl.java:4078)
            at org.apache.openjpa.kernel.DelegatingBroker.close(DelegatingBroker.java:1298)
            at org.apache.openjpa.persistence.EntityManagerImpl.close(EntityManagerImpl.java:1106)
            at org.apache.openejb.persistence.JtaEntityManagerRegistry$CloseEntityManager.afterCompletion(JtaEntityManagerRegistry.java:294)
            at org.apache.geronimo.transaction.manager.TransactionImpl.afterCompletion(TransactionImpl.java:534)
            at org.apache.geronimo.transaction.manager.TransactionImpl.afterCompletion(TransactionImpl.java:526)
            at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:326)
            at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:245)
            at org.apache.openejb.core.transaction.TransactionPolicy.commitTransaction(TransactionPolicy.java:138)
            at org.apache.openejb.core.transaction.TxRequiresNew.afterInvoke(TxRequiresNew.java:73)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:233)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
            at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:321)
            at org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
            at $Proxy67.record(Unknown Source)
            at com.kishware.core.gl.audit.ConcurrentTracker$5.call(ConcurrentTracker.java:123)
            at com.kishware.core.gl.audit.ConcurrentTracker$5.call(ConcurrentTracker.java:122)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
            at java.util.concurrent.FutureTask.run(FutureTask.java:123)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
            at java.lang.Thread.run(Thread.java:595)
            at com.kishware.common.thread.GeneralThread.run(GeneralThread.java:38)

javax.ejb.EJBTransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization: Unable to commit: transaction marked for rollback
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:348)
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:323)
            at org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
            at $Proxy65.editSubsidiaryEntry(Unknown Source)
            at com.kishware.core.gl.service.main.SubsidiaryLedgerImplTest.testEditEntry(SubsidiaryLedgerImplTest.java:55)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
            at com.intellij.rt.junit4.Junit4TestMethodAdapter.run(Junit4TestMethodAdapter.java:49)
            at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: javax.transaction.TransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization: Unable to commit: transaction marked for rollback
            at org.apache.openejb.core.transaction.TransactionPolicy.commitTransaction(TransactionPolicy.java:146)
            at org.apache.openejb.core.transaction.TxRequired.afterInvoke(TxRequired.java:76)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:233)
            at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
            at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
            at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
            at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:321)
            ... 28 more
--
Regards
Mohammad
Pixelshot
Reply | Threaded
Open this post in threaded view
|

Re: prblem with using stateless bean in StoreListener

stlecho
Have you found a solution ?
Reply | Threaded
Open this post in threaded view
|

Re: prblem with using stateless bean in StoreListener

Michael Dick
Administrator
It looks like the EntityManager was closed prior to the store listener calling afterStore()..

The EM was injected (apparently), since the call to close it was done by openejb. Is it possible that the listener has a stale EM?

-mike