3 Replies Latest reply on Mar 10, 2008 4:33 PM by Guillaume Jeudy

    Seam managed EM versus EJB-container managed EM

    Guillaume Jeudy Master

      My setup:


      jboss 4.2.2
      seam 2.0.1


      I'm using Seam managed EM in all my EJBs using @In.


      components.xml:


      
      <persistence:managed-persistence-context name="entityManager"
      
                auto-create="true"
      
                persistence-unit-jndi-name="java:/rdmEntityManagerFactory" />
      
      



      rdmEntityManagerFactory is bound to a jta-datasource (Oracle10g)


      The reason I do this is to set manual flush mode in a long running conversation in order to insure nothing is committed early in the database (if a query should contain an about to be persisted entity, the persisted entity would get flushed to the database right before the query executes).


      I have to implement cross-cutting logic in an EJB interceptor and apply it my session EJBs. This interceptor needs an entity manager. Should I use seam managed EM inside the interceptor, if so how can I achieve this?


      I was unable to make the interceptor a seam managed component (because the bijection didn't happen at the time of the interceptor execution), I had to use @PersistenceContext annotation to inject the entity manager. I don't use @Transactional annotation anywhere. (default transaction required should apply)


      I believe this causes me issues because I sometimes get the following exception:



      2008-03-07 16:17:08,781 DEBUG [org.hibernate.util.JDBCExceptionReporter] Cannot open connection [???]
      
      org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: afac77d:b42:47d1a578:13a status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: afac77d:b42:47d1a578:13a status: ActionStatus.ABORT_ONLY >)
      
           at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
      
           at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
      
           at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
      
           at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
      
           at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
      
           at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
      
           at org.hibernate.loader.Loader.doQuery(Loader.java:673)
      
           at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
      
           at org.hibernate.loader.Loader.doList(Loader.java:2220)
      
           at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
      
           at org.hibernate.loader.Loader.list(Loader.java:2099)
      
           at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
      
           at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
      
           at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
      
           at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
      
           at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:80)
      
           at com.archinsurance.rdmservices.stateless.impl.WorkspaceServiceImpl.su(WorkspaceServiceImpl.java:75)
      
           at com.archinsurance.rdmservices.stateless.impl.WorkspaceServiceImpl.gotoWorkspace(WorkspaceServiceImpl.java:37)
      
           at com.archinsurance.rdmservices.stateless.impl.WorkspaceServiceImpl.gotoWorkspace(WorkspaceServiceImpl.java:26)
      
           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.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      
           at com.archinsurance.rdmservices.interceptors.LoggingInterceptor.intercept(LoggingInterceptor.java:18)
      
           at sun.reflect.GeneratedMethodAccessor197.invoke(Unknown Source)
      
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
           at java.lang.reflect.Method.invoke(Method.java:585)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
           at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
      
           at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
      
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
           at java.lang.reflect.Method.invoke(Method.java:585)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
           at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
      
           at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
      
           at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
      
           at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
      
           at $Proxy385.gotoWorkspace(Unknown Source)
      
           at com.archinsurance.rdmservices.interceptors.CurrentWorkspaceInterceptor.intercept(CurrentWorkspaceInterceptor.java:36)
      
           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.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
           at com.archinsurance.rdmservices.interceptors.LoggingInterceptor.intercept(LoggingInterceptor.java:18)
      
           at sun.reflect.GeneratedMethodAccessor197.invoke(Unknown Source)
      
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
           at java.lang.reflect.Method.invoke(Method.java:585)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
           at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
      
           at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
      
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
           at java.lang.reflect.Method.invoke(Method.java:585)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
           at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
      
           at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
      
           at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
      
           at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
      
           at $Proxy412.getRelationDomainById(Unknown Source)
      
           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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
      
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
      
           at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      
           at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
      
           at org.javassist.tmp.java.lang.Object_$$_javassist_14.getRelationDomainById(Object_$$_javassist_14.java)
      
           at com.archinsurance.rdmservices.stateful.impl.RefDomRelateInstanceActionBean.init(RefDomRelateInstanceActionBean.java:87)
      
           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.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      
           at com.archinsurance.rdmservices.interceptors.LoggingInterceptor.intercept(LoggingInterceptor.java:18)
      
           at sun.reflect.GeneratedMethodAccessor197.invoke(Unknown Source)
      
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
           at java.lang.reflect.Method.invoke(Method.java:585)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
           at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
      
           at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
      
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
           at java.lang.reflect.Method.invoke(Method.java:585)
      
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      
           at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
      
           at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      
           at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
      
           at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
      
           at $Proxy381.init(Unknown Source)
      
           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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
      
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
      
           at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      
           at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
      
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      
           at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
      
           at org.javassist.tmp.java.lang.Object_$$_javassist_12.init(Object_$$_javassist_12.java)
      
           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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
      
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
      
           at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
      
           at org.jboss.seam.Component.callCreateMethod(Component.java:2005)
      
           at org.jboss.seam.Component.newInstance(Component.java:1976)
      
           at org.jboss.seam.Component.getInstance(Component.java:1873)
      
           at org.jboss.seam.Component.getInstance(Component.java:1840)
      
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
      
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
      
           at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
      
           at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
      
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
      
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
      
           at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
      
           at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
      
           at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      
           at javax.faces.component.UISelectItems.getValue(UISelectItems.java:130)
      
           at org.jboss.seam.ui.component.UISelectItems.getValue(UISelectItems.java:156)
      
           at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:323)
      
           at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:675)
      
           at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:793)
      
           at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
      
           at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
      
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
      
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
      
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
      
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
      
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
      
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
      
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
      
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
      
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
      
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
      
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
           at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:118)
      
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      
           at java.lang.Thread.run(Thread.java:595)
      
      Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: afac77d:b42:47d1a578:13a status: ActionStatus.ABORT_ONLY >
      
           at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:304)
      
           at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:396)
      
           at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
      
           at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
      
           ... 289 more
      
      2008-03-07 16:17:08,797 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: null
      
      2008-03-07 16:17:08,797 ERROR [org.hibernate.util.JDBCExceptionReporter] Transaction is not active: tx=TransactionImple < ac, BasicAction: afac77d:b42:47d1a578:13a status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: afac77d:b42:47d1a578:13a status: ActionStatus.ABORT_ONLY >)
      
      2008-03-07 16:17:08,797 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] mark transaction for rollback
      
      2008-03-07 16:17:08,797 DEBUG [org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor] ********************* CLOSING tx scoped nontx entity manager
      
      



      My guess is that the EJB3 transaction lifecycle is different for seam managed EM versus EJB container managed EM. If seam starts a transaction (not sure how this works under the hood) then @PersistenceContext injected entityManager have no guarantees to be using the same propagated transaction.


      Question1: Can @PersistenceContext and @In injection co-exist peacefully for EntityManager injection in my beans?


      Question2: How can I solve this should I inject seam managed EM in my interceptor ?  Can I make my interceptor a seam interceptor and therefore benefit seam DI? If so, can someone provide guidelines on how to do this?


      Thank you,
      -Guillaume


        • 1. Re: Seam managed EM versus EJB-container managed EM
          Nicklas Karlsson Master

          I would think injection should work with seam interceptors as per 5.2 in the docs. They returned null? Can you get access to components though Component.getInstance or Contexts.lookupIn...?

          • 2. Re: Seam managed EM versus EJB-container managed EM
            Gavin King Master

            I would think injection should work with seam interceptors as per 5.2 in the docs.

            No, I don't think so. You need to use Component.getInstance().

            • 3. Re: Seam managed EM versus EJB-container managed EM
              Guillaume Jeudy Master

              Thanks Gavin, I used Component.getInstance() and it indeed worked and retrieved a conversation scoped entityManager instance.


              The exception is still occurring. This is consistently happening for an SLSB method being called from an SFSB @Create method (conversation scoped). The SLSB method  is the one i'm applying my interceptor on. The interceptor is just a standard EJB interceptor from which I get a seam managed EM through Component.getInstance().


              The pattern is quite strange, apparently the @Create method is being called 3 times by the container during a single request cycle. It fails with the exception on the 3rd time. By looking at my code I think my SFSB should be created only once during the RENDER RESPONSE phase. It's referenced for the first time in the response page.


              Does the @Create annotation have additionnal restrictions regarding transactions/interceptors that I should be aware of ?


              Still investigating..