AnsweredAssumed Answered

LazyInitializationException when retrieving Workflows/tasks

Question asked by vycitalr on Apr 10, 2008
Latest reply on Jul 8, 2008 by jimcornmell
Hello,
I am having problems getting workflows/tasks. My system started to throw LazyIntializationExceptions as to getting TaskInstance's variableInstance. This seem to came into existence when there are more (eg. 50-100) workflows/tasks in system.  In other words, I get some TaskInstances via JBPMEngine.queryTasks(), and while fetching their VariableInstances I get the LazyInicializationException for some of the tasks while for others it is ok. And this happens in one transation. If I catch the errror and examine the sesssion, it says it is ok - "connected" and "open".   It seems to happen again and again for the same tasks, so they might be somewhat corrupted but could not see how.

The exact stacktrace is here

18:04:54,551 INFO  [STDOUT] 18:04:54,551 DEBUG [alfresco.repo.workflow] Detached (rollback) JBPM Context from transaction 56859328-04bc-11dd-bdef-c75961e062bb
18:04:54,552 INFO  [STDOUT] 18:04:54,552 ERROR [ui.common.Utils] Failed to get all active tasks: org.springframework.orm.hibernate3.HibernateSystemException: failed to lazily initialize a collection of role: or
g.jbpm.taskmgmt.exe.TaskInstance.variableInstances, no session or session was closed; nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.jbpm.ta
skmgmt.exe.TaskInstance.variableInstances, no session or session was closed
org.springframework.orm.hibernate3.HibernateSystemException: failed to lazily initialize a collection of role: org.jbpm.taskmgmt.exe.TaskInstance.variableInstances, no session or session was closed; nested exce
ption is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.jbpm.taskmgmt.exe.TaskInstance.variableInstances, no session or session was closed
Caused by:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.jbpm.taskmgmt.exe.TaskInstance.variableInstances, 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.initialize(AbstractPersistentCollection.java:343)
        at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
        at org.hibernate.collection.PersistentMap.entrySet(PersistentMap.java:242)
        at org.jbpm.context.exe.VariableContainer.getVariablesLocally(VariableContainer.java:103)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine.getTaskProperties(JBPMEngine.java:1932)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowTask(JBPMEngine.java:2800)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine$24.doInJbpm(JBPMEngine.java:1282)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine$24.doInJbpm(JBPMEngine.java:1259)
        at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:333)
        at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine.queryTasks(JBPMEngine.java:1257)
        at org.alfresco.repo.workflow.WorkflowServiceImpl.queryTasks(WorkflowServiceImpl.java:433)
        at sun.reflect.GeneratedMethodAccessor674.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:241)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
        at $Proxy124.queryTasks(Unknown Source)
        at com.cleverbee.web.bean.workflow.WorkflowBean.getAllActiveTasks(WorkflowBean.java:117)
        at com.cleverbee.web.bean.workflow.PrintableTaskBean.getTasks(PrintableTaskBean.java:128)
        at com.cleverbee.web.bean.workflow.AFilterredTaskBean.getInit(AFilterredTaskBean.java:83)
        at sun.reflect.GeneratedMethodAccessor673.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:457)
        at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:85)
        at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:535)
        at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
        at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:386)
        at javax.faces.component.UIOutput.getValue(UIOutput.java:80)
        at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:223)
        at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:69)
        at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:57)
        at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
        at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:419)
        at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren(RendererUtils.java:400)
        at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:417)

I just found these similliar issues that might be related, but it didn't help.

http://issues.alfresco.com/browse/WCM-1079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel
http://217.174.252.22/viewtopic.php?p=29820&sid=e683ffb5254f6338ef749309b296188c

I experinced this problem with PostgreSQL as well as with Oracle. I am using version 2.2.0 schema 105 on Linux Debian.

Thank you for any help.

Outcomes