Anup Nair [
http://community.jboss.org/people/wrecked] created the discussion
"Hibernate LazyInitializationException during swimlane creation"
To view the discussion, visit:
http://community.jboss.org/message/566066#566066
--------------------------------------------------------------
Hi All,
I am a new bie to this site. I am currently using jBPM 4 with Oracle as db.
I have created a sample workflow and using the JBPM API to create instances and moving
instance from one activity to another.
However when i am trying to create a swimlane programatically i am getting
*org.hibernate.LazyInitializationException*
*I am not getting an idea how the hibernate session gets closed.
*
Following is the code snippet for swimlane creation:
public void testAddParticipants() throws Exception{
ProcessInstance processInstance =
executionService.findProcessInstanceById("ServiceCenter.1");
EnvironmentImpl environment
=(EnvironmentImpl)((EnvironmentFactory)processService).openEnvironment();
try{
Collection<? extends Execution> executionMap =
processInstance.getExecutions();
for (Execution execution : executionMap) {
System.out.println(execution.getClass());
if(execution instanceof ExecutionImpl){
final ExecutionImpl exec = (ExecutionImpl) execution;
SwimlaneImpl role = exec.createSwimlane("approver");
System.out.println("Approver role added:"+role);
}
}
}finally{
environment.close();
}
}
The exception trace is:
### EXCEPTION ###########################################
[*LazyInitializationException] failed to lazily initialize a collection of role:
org.jbpm.pvm.internal.model.ExecutionImpl.swimlanes, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of
role: org.jbpm.pvm.internal.model.ExecutionImpl.swimlanes, no session or session was
closed*
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.PersistentMap.put(PersistentMap.java:184)
at org.jbpm.pvm.internal.model.ExecutionImpl.createSwimlane(ExecutionImpl.java:874)
at com.jpmc.servicecenter.ServiceCenter.testAddParticipants(ServiceCenter.java:304)
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:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
The jbpm.cfg.xml has the following configuration:
*<?xml version="1.0" encoding="UTF-8"?>*
**
*<jbpm-configuration>*
**
* <import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.tx.hibernate.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.task.hbm.xml" />*
**
* <!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included.
-->
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->*
**
*</jbpm-configuration>*
I am stuck with this error from the past 1 week.
please help me out.
Thanks in advance.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/566066#566066]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]