9 Replies Latest reply on Aug 29, 2007 3:28 PM by Waseem Quraishi

    LazyInitializationException

    drapierwimATgmailDOTcom Newbie

      As you can see I'm having a LazyInitializationException error that I can't seem to fix.

      First of all this stuff worked before just fine a couple months ago, the only thing changed is that I now use jBPM pageflow

      Here is a piece of my faces.config

      <lifecycle>
       <!--phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener-->
       <!--phase-listener>org.jboss.seam.jsf.SeamTransactionManagedPersistencePhaseListener</phase-listener-->
       <phase-listener>org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener</phase-listener>
       </lifecycle>
      

      Here is the web.xml
      <filter>
       <filter-name>Seam Exception Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
       </filter>
      
       <filter>
       <filter-name>Seam Redirect Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Seam Exception Filter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
       <filter-mapping>
       <filter-name>Seam Redirect Filter</filter-name>
       <url-pattern>*.seam</url-pattern>
       </filter-mapping>
      


      My statefullbean
      @Stateful
      @Name("accountsManager")
      @Scope(ScopeType.CONVERSATION)
      @Conversational(ifNotBegunOutcome="home_page")
      public class AccountsServiceBean implements AccountsService, Serializable {
      
       private static final Logger log = Logger.getLogger(AccountsServiceBean.class);
      
       @PersistenceContext(type=PersistenceContextType.EXTENDED)
       private EntityManager em;
      
       @DataModel(scope=ScopeType.PAGE)
       private List<Account> accounts;
       @DataModelSelectionIndex
       private int accountIndex;
      
       @Out(required=false, scope=ScopeType.PAGE)
       private Account bookAccount;
      
       private boolean lookupMode;
      
       public boolean isLookupMode() {
       return lookupMode;
       }
      
       private void setLookupMode(boolean lookupMode) {
       this.lookupMode = lookupMode;
       }
      
       public Account getAccount() {
       return bookAccount;
       }
      
       @Create
       public void create() {
       log.info("created");
       }
      
       //@Begin(join=true)
       @Factory("accounts")
       @SuppressWarnings("unchecked")
       public void load() {
       accounts = em.createQuery("from Account a " +
       "where a.number between 1 and 7")
       .getResultList();
       }
      
       public void find(){
       setLookupMode(true);
       load();
       }
      
       public void getChilderen() {
       bookAccount = accounts.get(accountIndex);
       accounts = ((SummaryAccount)bookAccount).getChildAccounts();
       }
      
       public void addNew() {
      
       }
      
       public void delete() {
      
       }
      
       @Begin(nested=true)
       public String lookup() {
       setLookupMode(true);
       find();
       return "accounts_page";
       }
      
       @End
       public void select() {
       setLookupMode(false);
       bookAccount = accounts.get(accountIndex);
       }
      
       @Destroy
       public void destroy() {
       log.info("destroyed");
       }
      

      Stacktrace...
      15:11:38,413 ERROR [LazyInitializationException] failed to lazily initialize a collection of role: be.drapier.domain.SummaryAccount.childAccounts, no session or session was closed
      org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: be.drapier.domain.SummaryAccount.childAccounts, no session or session was closed
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
       at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
       at org.hibernate.collection.PersistentBag.size(PersistentBag.java:222)
       at javax.faces.model.ListDataModel.isRowAvailable(ListDataModel.java:82)
       at javax.faces.model.ListDataModel.setRowIndex(ListDataModel.java:95)
       at javax.faces.model.ListDataModel.setWrappedData(ListDataModel.java:109)
       at javax.faces.model.ListDataModel.<init>(ListDataModel.java:40)
       at org.jboss.seam.jsf.ListDataModel.<init>(ListDataModel.java:31)
       at org.jboss.seam.Component.outjectDataModelList(Component.java:847)
       at org.jboss.seam.Component.outjectDataModel(Component.java:829)
       at org.jboss.seam.Component.outject(Component.java:744)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:41)
       at sun.reflect.GeneratedMethodAccessor519.invoke(Unknown Source)
       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:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:68)
       at sun.reflect.GeneratedMethodAccessor518.invoke(Unknown Source)
       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:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:60)
       at sun.reflect.GeneratedMethodAccessor517.invoke(Unknown Source)
       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:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
       at sun.reflect.GeneratedMethodAccessor516.invoke(Unknown Source)
       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:13)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:87)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:73)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45)
       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:120)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:196)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:199)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy290.getChilderen(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 com.sun.el.parser.AstValue.invoke(AstValue.java:130)
       at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIData.broadcast(UIData.java:338)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      15:11:38,504 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
      javax.servlet.ServletException: Error calling action method of component with id _id0_2:_id2
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      15:11:38,534 INFO [SeamExceptionFilter] killing transaction
      15:11:38,534 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.FacesException: Error calling action method of component with id _id0_2:_id2
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIData.broadcast(UIData.java:338)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.faces.el.EvaluationException: /accounts.xhtml @31,33 action="#{accountsManager.getChilderen}": java.lang.RuntimeException: javax.transaction.RollbackException: Already marked for rollback TransactionImpl:XidImpl[FormatId=257, GlobalId=CPQ12864253737/161, BranchQual=, localId=161]
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       ... 32 more
      Caused by: java.lang.RuntimeException: javax.transaction.RollbackException: Already marked for rollback TransactionImpl:XidImpl[FormatId=257, GlobalId=CPQ12864253737/161, BranchQual=, localId=161]
       at org.jboss.ejb3.stateful.StatefulBeanContext.remove(StatefulBeanContext.java:270)
       at org.jboss.ejb3.AbstractPool.remove(AbstractPool.java:171)
       at org.jboss.ejb3.cache.simple.SimpleStatefulCache.remove(SimpleStatefulCache.java:284)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:89)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:199)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy290.getChilderen(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 com.sun.el.parser.AstValue.invoke(AstValue.java:130)
       at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
       ... 33 more
      Caused by: javax.transaction.RollbackException: Already marked for rollback TransactionImpl:XidImpl[FormatId=257, GlobalId=CPQ12864253737/161, BranchQual=, localId=161]
       at org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:632)
       at org.jboss.ejb3.stateful.StatefulBeanContext.remove(StatefulBeanContext.java:257)
       ... 54 more
      


        • 1. Re: LazyInitializationException
          drapierwimATgmailDOTcom Newbie

          I've read the doc and made some changes... with no success

          added in the web.xml

          <context-param>
           <param-name>org.jboss.seam.core.init.managedPersistenceContexts</param-name>
           <param-value>accountingDatabase</param-value>
           </context-param>
          
           <context-param>
           param-name>bookingDatabase.persistenceUnitJndiName</param-name>
           <param-value>java:/EntityManagerFactories/accountingData</param-value>
           </context-param>


          changed my bean
          //@PersistenceContext(type=PersistenceContextType.EXTENDED)
           @In(create=true)
           private EntityManager accountingData;


          • 2. Re: LazyInitializationException
            drapierwimATgmailDOTcom Newbie

            Thanks to my servers log file and the issues example project I've come a step closer.
            Seems now I'm stuck with this

            2006-05-06 22:44:47,563 DEBUG [org.jbpm.graph.def.GraphElement] executing action '#{accountsManager.find}'
            2006-05-06 22:44:47,563 DEBUG [org.jboss.seam.Component] instantiating Seam component: accountsManager
            2006-05-06 22:44:47,563 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
            2006-05-06 22:44:47,593 DEBUG [org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor] ++++ LongLivedSessionPropagationInterceptor
            2006-05-06 22:44:47,593 DEBUG [org.jboss.seam.Component] instantiating Seam component: entityManager
            2006-05-06 22:44:47,603 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
            2006-05-06 22:44:47,603 ERROR [STDERR] java.lang.IllegalArgumentException: EntityManagerFactory not found
            2006-05-06 22:44:47,613 ERROR [STDERR] at org.jboss.seam.core.ManagedPersistenceContext.create(ManagedPersistenceContext.java:59)
            2006-05-06 22:44:47,613 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


            • 3. Re: LazyInitializationException
              Gavin King Master

              Have you set jboss.entity.manager.factory.jndi.name in persistence.xml?

              • 4. Re: LazyInitializationException
                drapierwimATgmailDOTcom Newbie

                 

                "gavin.king@jboss.com" wrote:
                Have you set jboss.entity.manager.factory.jndi.name in persistence.xml?


                This is my entry in the persistence.xml
                <property name="jboss.entity.manager.factory.jndi.name" value="java:/accountingEntityManagerFactory"/>
                


                The value only references a context-param in my web.xml
                <context-param>
                <param-name>accountingDatabase.persistenceUnitJndiName</param-name>
                <param-value>java:/accountingEntityManagerFactory</param-value>
                </context-param>


                But I don't understand what should reference the param-name.

                • 5. Re: LazyInitializationException
                  drapierwimATgmailDOTcom Newbie

                  I've found the problem the param-name was wrong in the web.xml instead of accountingDatabase.persistenceUnitJndiName it schould be entityManager.persistenceUnitJndiName.

                  But after a quick test I still got

                  08:58:03,473 ERROR [LazyInitializationException] failed to lazily initialize a collection of role: be.drapier.domain.SummaryAccount.childAccounts, no session or session was closed
                  org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: be.drapier.domain.SummaryAccount.childAccounts, no session or session was closed
                  




                  • 6. Re: LazyInitializationException
                    Gavin King Master

                    Use

                    @In(create=true)
                    EntityManager entityManager


                    For Seam-managed EMs.

                    • 7. Re: LazyInitializationException
                      drapierwimATgmailDOTcom Newbie

                      Ok I'm kind of stuck here... so I will do my best to explain.
                      I've read in the seam documentation the following


                      Seam completely solves the problem of unwanted LazyInitializationExceptions, while working around the biggest problem in the open session in view pattern. The solution comes in two parts:

                      * use an extended persistence context that is scoped to the conversation,
                      instead of to the request
                      * use two transactions per request; the first spans the beginning of the
                      update model values phase until the end of the invoke application phase;
                      the second spans the render response phase


                      I migrated to a jBPM by using a pageflow definition, this makes use of MULTIPLE SFSB in these SFSB there are @Begin and @End annotations.

                      Since a pageflow is a conversation itself I think that these LazyInitializationExceptions occur because I'm still using the @Begin and @ End annotations. I'm I right here?

                      So a solution for this could be to create ONE SFSB that covers the whole proccess that uses the pageflow definition or by using the nested=true property for the @Begin annotation in all my SFSB.

                      What exactly opens and closes a session?


                      • 8. Re: LazyInitializationException
                        Gavin King Master

                        As long as you are injecting the Seam-managed EPC, and not an EJB-container-managed EPC, and as long as you remain in a single conversation, you will not get an LIE. It does not matter how many SFSBs you have. Of course, as soon as you @End the conversation, you can get an LIE.

                        • 9. Re: LazyInitializationException
                          Waseem Quraishi Newbie

                          One thing I discovered is if you override the toString() method and output the relationships, it'll force the container to load the relationship related fields. I'm thinking it accomplishes the same thing as fetchtype.eager but i've had more luck with this. Plus it works dual fold since I use the toString() method in conjunction with facesMessages to display what the object coming back is.