1 Reply Latest reply on Oct 13, 2009 9:52 AM by Murat HAZER

    spring seam persistence context & transaction sharing

    Murat HAZER Newbie

      I configured my application to use spring managed sessions and transactions in seam components and conversations as described Dan Allens Seam in Action Bonus Chapter. At first glance everthing works fine excepts i see the following error in the log files ...


      also i have following configuration in components.xml




      <spring:spring-transaction 
           platform-transaction-manager="#{transactionManager}" 
           conversation-context-required="#{false}"
           join-transaction="true" />



      any ideas?


      16:08:03,916  INFO Component:236 - Component: org.jboss.seam.transaction.facesTransactionEvents, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.transaction.FacesTransactionEvents
      16:08:03,916  INFO Component:236 - Component: org.jboss.seam.transaction.synchronizations, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.transaction.SeSynchronizations
      16:08:03,931  INFO Component:236 - Component: org.jboss.seam.transaction.transaction, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.ioc.spring.SpringTransaction
      
      .....
      
      16:08:04,166  INFO Component:236 - Component: springManagedHibernateSession, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.ManagedHibernateSession
      
      ....
      
      
      16:13:08,664  WARN Component:2025 - Cannot create Seam component, scope is not active: springManagedHibernateSession(CONVERSATION)
      16:13:08,664 ERROR SeamPhaseListener:130 - swallowing exception
      java.lang.IllegalStateException: Could not start transaction
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:598)
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:583)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:327)
           at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:144)
           at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
           at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
           at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:102)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
           at com.icesoft.faces.context.View$2$1.respond(View.java:48)
           at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:201)
           at com.icesoft.faces.context.View$2.serve(View.java:77)
           at com.icesoft.faces.context.View.servePage(View.java:149)
           at com.icesoft.faces.webapp.http.core.MultiViewServer.service(MultiViewServer.java:67)
           at com.icesoft.faces.webapp.http.common.ServerProxy.service(ServerProxy.java:11)
           at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet$4.service(MainSessionBoundServlet.java:149)
           at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
           at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
           at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
           at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
           at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
           at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
           at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
           at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1124)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
           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.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
           at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)
           at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
           at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
           at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
           at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
           at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
           at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
           at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
           at org.mortbay.jetty.Server.handle(Server.java:324)
           at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
           at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
           at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:538)
           at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
           at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
           at org.mortbay.jetty.nio.BlockingChannelConnector$Connection.run(BlockingChannelConnector.java:163)
           at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
      Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.IllegalArgumentException: Instance must not be null
           at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:599)
           at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
           at org.jboss.seam.ioc.spring.SpringTransaction.begin(SpringTransaction.java:67)
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:593)
           ... 54 more
      Caused by: java.lang.IllegalArgumentException: Instance must not be null
           at org.springframework.util.Assert.notNull(Assert.java:112)
           at org.springframework.util.ClassUtils.getAllInterfaces(ClassUtils.java:854)
           at 
      
      org.jboss.seam.ioc.spring.SeamManagedSessionFactoryBean$SeamManagedSessionFactoryHandler.invoke(SeamManagedSessionFactoryBean.java:192)
           at $Proxy48.openSession(Unknown Source)
           at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:493)
           ... 57 more





        • 1. Re: spring seam persistence context & transaction sharing
          Murat HAZER Newbie

          i removed the


          conversation-context-required="#{false}"



          property from spring transaction definition in the components.xml and exception gone. But Seam in Action's 15th chapter says;



          When using the JTA transaction strategy, or a resource-local transaction that
          doesn’t use a Seam-managed persistence context, you can provide Seam with a hint
          that the transaction manager isn’t dependent on the conversation context by setting
          the conversation-context-required property to false on the Spring transaction
          component:


          <spring:spring-transaction platform-transaction-manager="#{txManager}"
          conversation-context-required="false">




          The default value of the conversation-context-required is true, which will force
          Seam to wait until the conversation has started to begin the first global transaction.

          i understand that if i use spring  managed persistence context i should set

          conversation-context-required="#{true}"

          .


          is this correct or i understand something wrong?


          regards ...