5 Replies Latest reply on May 19, 2009 9:34 PM by youngm

    Transaction integration (concurrency?) failure: Spring + Seam

    Francisco Jose Peredo Noguez Master

      Hi!
      I am working with Seam 2.1.1.GA I have a page with a link to edit a Pojo (very similar to the edit link in a base seam-gen application), if the user clicks this edit link many times (like users typically do when the network is slow) I get the following exception:


      
      org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException
      
      



      I am integrating Seam and Spring EntityManager as described in this article (and in Dan Allen book).


      On a fast network only happens if the edit link is clicked fast many times (in a slow network 2 o 3 clicks will do the trick). I guess the root cause is somekind of concurrency issue between Seam and Spring...


      Any hints?


      Here is the full Stack trace:


      
      2009-04-15 12:29:33,757 ERROR org.jboss.seam.exception.Exceptions - handled and logged exception
      java.lang.IllegalStateException: Could not start transaction
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:599) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:584) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:325) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:142) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214) [jsf-impl-working@webapplibraries.jar:1.2_09-b01-BETA1]
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96) [jsf-impl-working@webapplibraries.jar:1.2_09-b01-BETA1]
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-working@webapplibraries.jar:1.2_09-b01-BETA1]
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266) [jsf-api-working@webapplibraries.jar:1.2_09-b01-BETA1]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) [catalina.jar:na]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177) [richfaces-impl-working@webapplibraries.jar:3.2.2.GA]
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267) [richfaces-impl-working@webapplibraries.jar:3.2.2.GA]
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380) [richfaces-impl-working@webapplibraries.jar:3.2.2.GA]
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507) [richfaces-impl-working@webapplibraries.jar:3.2.2.GA]
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) [catalina.jar:na]
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) [catalina.jar:na]
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) [catalina.jar:na]
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) [catalina.jar:na]
           at org.jstripe.tomcat.probe.Tomcat55AgentValve.invoke(Tomcat55AgentValve.java:20) [Tomcat55AgentValve.class:na]
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [catalina.jar:na]
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [catalina.jar:na]
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) [catalina.jar:na]
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) [tomcat-coyote.jar:na]
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) [tomcat-coyote.jar:na]
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) [tomcat-coyote.jar:na]
           at java.lang.Thread.run(Thread.java:619) [na:1.6.0_06]
      Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException
           at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:379) [spring-working@webapplibraries.jar:2.5.1]
           at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377) [spring-working@webapplibraries.jar:2.5.1]
           at org.jboss.seam.ioc.spring.SpringTransaction.begin(SpringTransaction.java:67) [jboss-seam-ioc-working@webapplibraries.jar:2.1.1.GA]
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:594) [jboss-seam-working@webapplibraries.jar:2.1.1.GA]
           ... 42 common frames omitted
      Caused by: java.lang.NullPointerException
           at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57) [hibernate-working@webapplibraries.jar:3.2.4.sp1]
           at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326) [hibernate-working@webapplibraries.jar:3.2.4.sp1]
           at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:38) [hibernate-entitymanager-working@webapplibraries.jar:na]
           at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70) [spring-working@webapplibraries.jar:2.5.1]
           at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:330) [spring-working@webapplibraries.jar:2.5.1]
           ... 45 common frames omitted