1 Reply Latest reply on Jun 9, 2012 4:13 PM by gebuh

    transaction is not active

    Syed Musavvir Newbie

      Dear All,

       

      We are using seam in our project. I am new to seam, can someonehelp me to solve below issue.

       

      In below code I am inserting a record in DB, if PersistenceException is occured (ConstraintViolationException) then I am trying to update the same record. while updating the record in catch bloack I am getting below exception.

       

      For me it looks transaction is got closed on PersistenceException. Can any one help me?

       

                 try{              

                      saveEp2Terminal(terminal, true);             

                     }catch(PersistenceException pex){                   

                          //on violation of unique constraint update TerminalInfo invoked

                          updateTerminalInfo(terminal);

                     }

       

       

      16:59:11,220 ERROR [TerminalManager] Unknow exception -> org.hibernate.exception.GenericJDBCException: Cannot open connection

      javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection

                at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)

                at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:103)

                at com.accarda.terminalmanagerSV.service.TerminalService.findEp2Terminal(TerminalService.java:586)

                at com.accarda.terminalmanagerSV.service.TerminalService.realSetTerminalInfo(TerminalService.java:132)

                at com.accarda.terminalmanagerSV.service.TerminalService.setTerminalInfo(TerminalService.java:107)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

                at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

                at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)

                at org.jboss.seam.util.Work.workInTransaction(Work.java:61)

                at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)

                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.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)

                at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)

                at com.accarda.terminalmanagerSV.service.TerminalService_$$_javassist_seam_3.setTerminalInfo(TerminalService_$$_javassist_seam_3.java)

                at com.accarda.terminalmanagerSV.ws.impl.TerminalManager.setTerminalInfo(TerminalManager.java:75)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

                at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

                at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)

                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.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)

                at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)

                at com.accarda.terminalmanagerSV.ws.impl.TerminalManager_$$_javassist_seam_2.setTerminalInfo(TerminalManager_$$_javassist_seam_2.java)

                at com.accarda.terminalmanagerSV.ws.impl.TerminalManagerPortImpl.setTerminalInfo(TerminalManagerPortImpl.java:44)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)

                at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72)

                at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:138)

                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:28)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29)

                at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:30)

                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.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:83)

                at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:70)

                at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:62)

                at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:76)

                at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:62)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)

                at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_9956648.invoke(InvocationContextInterceptor_z_fillMethod_9956648.java)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)

                at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_9956648.invoke(InvocationContextInterceptor_z_setup_9956648.java)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)

                at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:201)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:182)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86)

                at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

                at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:244)

                at org.jboss.ejb3.stateless.StatelessContainer.invokeEndpoint(StatelessContainer.java:612)

                at org.jboss.wsf.container.jboss50.invocation.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:106)

                at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:241)

                at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:470)

                at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:294)

                at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:203)

                at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:129)

                at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                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:235)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

                at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)

                at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)

                at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

                at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

                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:158)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.internalProcess(ActiveRequestResponseCacheValve.java:74)

                at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:47)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:599)

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)

                at java.lang.Thread.run(Unknown Source)

      Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection

                at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)

                at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)

                at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)

                at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)

                at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)

                at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)

                at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)

                at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1762)

                at org.hibernate.loader.Loader.doQuery(Loader.java:839)

                at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:298)

                at org.hibernate.loader.Loader.doList(Loader.java:2455)

                at org.hibernate.loader.Loader.doList(Loader.java:2440)

                at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2316)

                at org.hibernate.loader.Loader.list(Loader.java:2311)

                at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:414)

                at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:364)

                at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)

                at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1192)

                at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)

                at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:94)

                ... 149 more

      Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a550626:d389:4fce1388:dc status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a550626:d389:4fce1388:dc status: ActionStatus.ABORT_ONLY >)

                at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)

                at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)

                at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)

                ... 164 more

      Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a550626:d389:4fce1388:dc status: ActionStatus.ABORT_ONLY >

                at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:413)

                at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)

                at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)

                at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)

                ... 166 more

        • 1. Re: transaction is not active
          gebuh Newbie

          What does your save method look like?  I would think rather then try to save and then update if the row already exists it would be better to use entityManager.find to find the object in the persistence context or just entityManager.merge which will persist the entity if it's not in the db or update it if it is.  There are some shades of nuance to using merge that need to be considered though.