5 Replies Latest reply on May 22, 2008 11:46 AM by Jaime Martin

    transactions and session scope

    Jaime Martin Apprentice

      hi,
      I have an EntityHome child class. If I invoke its update method it works ok as always. But now I´ve changed the default scope (conversation) to a session one. Ever since, when I invoke the update method I have this error:



      19:01:17,096 ERROR [STDERR] javax.persistence.TransactionRequiredException: no transaction is in progress
      19:01:17,096 ERROR [STDERR]      at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:293)
      19:01:17,096 ERROR [STDERR]      at org.jboss.seam.persistence.EntityManagerProxy.flush(EntityManagerProxy.java:90)
      19:01:17,096 ERROR [STDERR]      at org.jboss.seam.framework.EntityHome.update(EntityHome.java:64)
      19:01:17,299 ERROR [STDERR]      at es.rbcdexia.risk.online.action.PrrUserHome.selectLanguage(PrrUserHome.java:156)
      19:01:17,299 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      
      19:01:17,299 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:17,299 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:17,299 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:597)
      19:01:17,315 ERROR [STDERR]      at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
      19:01:17,315 ERROR [STDERR]      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
      19:01:17,315 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      19:01:17,315 ERROR [STDERR]      at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
      19:01:17,315 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.util.Work.workInTransaction(Work.java:40)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
      
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
      19:01:17,815 ERROR [STDERR]      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
      19:01:18,315 ERROR [STDERR]      at es.rbcdexia.risk.online.action.PrrUserHome_$$_javassist_3.selectLanguage(PrrUserHome_$$_javassist_3.java)
      19:01:18,315 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:18,315 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:18,315 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:18,315 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:597)
      19:01:18,315 ERROR [STDERR]      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
      19:01:18,315 ERROR [STDERR]      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:274)
      19:01:18,315 ERROR [STDERR]      at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
      19:01:18,315 ERROR [STDERR]      at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
      19:01:18,315 ERROR [STDERR]      at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
      19:01:18,315 ERROR [STDERR]      at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      19:01:18,815 ERROR [STDERR]      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
      19:01:18,815 ERROR [STDERR]      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
      19:01:18,815 ERROR [STDERR]      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
      19:01:18,815 ERROR [STDERR]      at javax.faces.component.UICommand.broadcast(UICommand.java:383)
      19:01:18,815 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:316)
      19:01:19,315 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:291)
      19:01:19,315 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:248)
      19:01:19,315 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:461)
      19:01:19,315 ERROR [STDERR]      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
      19:01:19,315 ERROR [STDERR]      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      19:01:19,815 ERROR [STDERR]      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      19:01:19,815 ERROR [STDERR]      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      19:01:19,815 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      19:01:19,815 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      19:01:19,815 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      19:01:20,315 ERROR [STDERR]      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      19:01:20,315 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      19:01:20,315 ERROR [STDERR]      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      19:01:20,315 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      19:01:20,315 ERROR [STDERR]      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      19:01:20,815 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      19:01:20,815 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
      19:01:20,815 ERROR [STDERR]      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
      19:01:20,815 ERROR [STDERR]      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
      19:01:20,815 ERROR [STDERR]      at org.ajax4jsf.Filter.doFilter(Filter.java:175)
      19:01:20,815 ERROR [STDERR]      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      19:01:20,815 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      19:01:20,815 ERROR [STDERR]      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      19:01:20,815 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      19:01:20,815 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      19:01:20,815 ERROR [STDERR]      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      19:01:20,815 ERROR [STDERR]      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      19:01:20,815 ERROR [STDERR]      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      19:01:20,815 ERROR [STDERR]      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      19:01:20,815 ERROR [STDERR]      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      19:01:20,815 ERROR [STDERR]      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      19:01:20,815 ERROR [STDERR]      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      19:01:20,815 ERROR [STDERR]      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      19:01:20,815 ERROR [STDERR]      at java.lang.Thread.run(Thread.java:619)
      



      I´ve overriden the method and added
      this.joinTransaction();
      as well as @Transactional annotation. but it does not work.
      It works only if I remove the session scope annotation, but I want it for other purposes.


      It is not possible to use transactions with a session scope entityhome child class? I guess I´m doing something wrong, but I do not know what it is!
      Btw, I´m using seam 201GA with pojos and JBoss 422.
      thank you!


        • 1. Re: transactions and session scope
          Jaime Martin Apprentice

          Now I am using latest SEAM 2.0.2.GA in case there was something related with JBSEAM-2780 or 2913 was, but without success.


          I checked that with the default scope (conversation) the entityhome child class has a true value for this.getEntityManager().isOpen(), and it turns out to be false just by adding session scope.
          When that is false I have the error


          javax.persistence.TransactionRequiredException: no transaction is in progress
          



          On the other hand I.ve tried as well with a javax.persistence.Query with othis method


              @Transactional
              public String updateLanguage() {
                  try {
                      Query updateQ = this.getEntityManager().createQuery("update PrrUser user set user.languageCode = :newLang where user.username = :usern");
                      updateQ.setParameter("newLang", this.getInstance().getLanguageCode());
                      updateQ.setParameter("usern", this.getInstance().getUsername());
                      updateQ.executeUpdate();
                  } catch (Exception ex) {
                      System.out.println("PrrUser UPDATE Exception!!! ex.getMessage----->" + ex.getMessage() + "<-----");
                      ex.printStackTrace();
                  }
                  this.getEntityManager().clear();
                  this.clearInstance();
                  return "PRR_USER_UPDATE";
              }
          
          



          It works perfect, just until the session scope is added. Then this error appears:


          13:26:15,111 ERROR [STDERR] java.lang.IllegalStateException: EntityManager is closed
          13:26:15,111 ERROR [STDERR]      at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:42)
          13:26:15,111 ERROR [STDERR]      at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
          13:26:15,111 ERROR [STDERR]      at org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManagerProxy.java:79)
          13:26:15,111 ERROR [STDERR]      at es.rbcdexia.risk.online.action.PrrUserHome.updateLanguage(PrrUserHome.java:97)
          13:26:15,111 ERROR [STDERR]      at es.rbcdexia.risk.online.action.PrrUserHome.selectLanguage(PrrUserHome.java:169)
          13:26:15,611 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          13:26:15,611 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          13:26:15,611 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          13:26:15,611 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:597)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.util.Work.workInTransaction(Work.java:41)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
          13:26:15,611 ERROR [STDERR]      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
          13:26:15,611 ERROR [STDERR]      at es.rbcdexia.risk.online.action.PrrUserHome_$$_javassist_3.selectLanguage(PrrUserHome_$$_javassist_3.java)
          13:26:15,611 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          13:26:15,611 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          13:26:15,611 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          13:26:15,611 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:597)
          13:26:15,611 ERROR [STDERR]      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
          13:26:15,611 ERROR [STDERR]      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:274)
          13:26:15,611 ERROR [STDERR]      at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
          13:26:15,611 ERROR [STDERR]      at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
          13:26:15,611 ERROR [STDERR]      at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
          13:26:15,611 ERROR [STDERR]      at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
          13:26:16,111 ERROR [STDERR]      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
          13:26:16,111 ERROR [STDERR]      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
          13:26:16,111 ERROR [STDERR]      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
          13:26:16,111 ERROR [STDERR]      at javax.faces.component.UICommand.broadcast(UICommand.java:383)
          13:26:16,111 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:316)
          13:26:16,111 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:291)
          13:26:16,111 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:248)
          13:26:16,111 ERROR [STDERR]      at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:461)
          13:26:16,111 ERROR [STDERR]      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
          13:26:16,111 ERROR [STDERR]      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
          13:26:16,111 ERROR [STDERR]      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
          13:26:16,111 ERROR [STDERR]      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
          
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
          13:26:16,111 ERROR [STDERR]      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
          13:26:16,111 ERROR [STDERR]      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
          13:26:16,111 ERROR [STDERR]      at org.ajax4jsf.Filter.doFilter(Filter.java:175)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
          13:26:16,111 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          13:26:16,111 ERROR [STDERR]      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
          13:26:16,111 ERROR [STDERR]      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          13:26:16,111 ERROR [STDERR]      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
          13:26:16,611 ERROR [STDERR]      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
          13:26:16,611 ERROR [STDERR]      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
          13:26:16,611 ERROR [STDERR]      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          13:26:16,611 ERROR [STDERR]      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          13:26:16,611 ERROR [STDERR]      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
          13:26:16,611 ERROR [STDERR]      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          13:26:16,611 ERROR [STDERR]      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
          13:26:16,611 ERROR [STDERR]      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
          13:26:16,611 ERROR [STDERR]      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
          13:26:16,611 ERROR [STDERR]      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
          13:26:16,611 ERROR [STDERR]      at java.lang.Thread.run(Thread.java:619)
          



          I have tried this, but it has not helped.


          this.getEntityManager().joinTransaction();
          this.joinTransaction();
          



          any idea? Apart from Transactional annotation is there anything compulsory or advisable to be added to have persistence with a class extending from EntityHome?
          thanks in advance!



          • 2. Re: transactions and session scope
            Pete Muir Master

            Inject the entity manager using @In.

            • 3. Re: transactions and session scope
              Jaime Martin Apprentice

              thank you Pete, but the same error goes on.


              I have the following:


              @Name("prrUserHome")
              @Scope (org.jboss.seam.ScopeType.SESSION)
              public class PrrUserHome extends EntityHome<PrrUser> {
                      
                      @Logger
                      Log log;
                      @In (create=true,required=false)        
                      private EntityManager em;                
              ..
              
                  @Transactional
                  public String updateLanguage() {
                      try {
                          System.out.println("!!!!updateLanguage EntityManager.isOpen ---->" + this.getEntityManager().isOpen() +"<--");
                          //this fails
                          //Query updateQ = this.getEntityManager().createQuery("update PrrUser user set user.languageCode = :newLang where user.username = :usern");
                          //this fails as well
                          Query updateQ = em.createQuery("update PrrUser user set user.languageCode = :newLang where user.username = :usern");
                          updateQ.setParameter("newLang", this.getInstance().getLanguageCode());
                          updateQ.setParameter("usern", this.getInstance().getUsername());
                          updateQ.executeUpdate();
                      } catch (Exception ex) {
                          System.out.println("PrrUser UPDATE Exception!!! ex.getMessage----->" + ex.getMessage() + "<-----");
                          ex.printStackTrace();
                      }
                      this.getEntityManager().clear();
                      this.clearInstance();
                      return "PRR_USER_UPDATE";
                  }        
                      
              



              With session scope, invoking prrUserHome.updateLanguage()
              or prrUserHome.update() fails.
              As for prrUserHome.updateLanguage no matter whether using injected EntityManager or this.getEntityManager().
              All of them work removing session scope, but I need that scope.


              In my components.xml I have defined it this way:(seam-gened)


                  <persistence:managed-persistence-context name="entityManager"
                                                           auto-create="true"
                                                           entity-manager-factory="#{PRR_ONLINEV2EntityManagerFactory}"/>
                  
                  <persistence:entity-manager-factory name="PRR_ONLINEV2EntityManagerFactory"
                                                      persistence-unit-name="PRR_ONLINEV2"/>
              



              any further idea?
              thank you!!

              • 4. Re: transactions and session scope
                Jaime Martin Apprentice

                Pete, my apologies because I realised I haven´t used the entityManager I have defined in components.xml. It´s entityManager, not em!!
                So injecting this way:


                        @In
                        private EntityManager entityManager;        
                



                my updateLanguage method works ok, and I test that entityManager.isOpen() is true. And it works with session scope as expected.



                Last but not least, if I just want to use EntityHome update() it does not work with session scope.
                Before invoking the update method I set the id, but with session scope it fails due to a no transaction is in progress error.
                (with conversation scope it works)


                Howewer if I manually assign my injected entityManager to the entityhome it works with session scope. So, just adding this:


                this.setEntityManager(entityManager); 
                //now invoking update works ok, and getEntityManager()isOpen is true
                this.update();   
                



                The fact of having to set this puzzles me, because father´s getPersistenceContextName returns entityManager, as defined in components.xml. I´ve seen in entityHome.java that it´s the default value, as expected.



                So, if you want to use update() or other framework persistence methods for an entity with a session scope from an entityHome child class in a pojo app (no EJB), are you supposed to set always the entityManager defined in components.xml?
                Maybe is this something related to my config?


                thank you very much!








                • 5. Re: transactions and session scope
                  Jaime Martin Apprentice

                  I´ll close myself this issue.
                  As suggested in the manual (btw guys, congratulations for the doc improvements) I´ve overriden getEntitymanager by extension, and problems are gone:


                          @Override
                          public EntityManager getEntityManager() {
                              return entityManager;
                          }