1 Reply Latest reply on Oct 27, 2009 3:06 AM by Sebastian Schneider

    [JBPM 4.1] could not initialize proxy - no Session

    David Loiseau Newbie

      I have a "could not initialize proxy" exception in a workflow when I try to get the process definition id from tasks which are between a fork and a join. The problem doesn't occur if I have not a split/join implementation.

      Process Definition:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process key="id" name="id" xmlns="http://jbpm.org/4.0/jpdl">
       <start g="123,34,32,29" name="start1">
       <transition to="fork2"/>
       </start>
       <end g="137,339,120,108" name="end1"/>
       <join g="-52,68,42,30" name="join1"/>
       <fork g="126,108,46,26" name="fork2">
       <transition to="task1"/>
       <transition to="task2"/>
       </fork>
       <task assignee="test" g="70,189,71,53" name="task1">
       <transition to="join2"/>
       </task>
       <task assignee="test" g="167,189,83,49" name="task2">
       <transition to="join2"/>
       </task>
       <join g="136,262,58,45" name="join2">
       <transition to="end1"/>
       </join>
      </process>


      Test case:

      package org.jbpm.examples.processdefinition.id;
      
      import java.util.List;
      import org.jbpm.api.Execution;
      import org.jbpm.api.ProcessInstance;
      import org.jbpm.api.task.Task;
      import org.jbpm.test.JbpmTestCase;
      
      /**
       * @author David Loiseau
       */
      
      public class ProcessDefinitionIdTest extends JbpmTestCase {
      
      
       String deploymentId;
      
       protected void setUp() throws Exception {
       super.setUp();
      
       deploymentId = repositoryService.createDeployment()
       .addResourceFromClasspath("org/jbpm/examples/processdefinition/id/process.jpdl.xml")
       .deploy();
       }
      
       public void testFindProcessDefinitionIdFromExecution(){
       String actorName = "test";
       ProcessInstance processInstance = executionService.startProcessInstanceByKey("id");
       List<Task> tasks = taskService.findPersonalTasks(actorName);
       for(Task task : tasks){
       Execution execution = processEngine.getExecutionService().findExecutionById(task.getExecutionId());
       String processDefinitionId = execution.getProcessInstance().getProcessDefinitionId();
       assertNotNull(processDefinitionId);
       }
       }
      
       protected void tearDown() throws Exception {
       repositoryService.deleteDeploymentCascade(deploymentId);
      
       super.tearDown();
       }
      
      
      }
      


      Exception:

      ### EXCEPTION ###########################################
      17:26:39,203 SEV | [BaseJbpmTestCase] TEST THROWS EXCEPTION: could not initialize proxy - no Session
      org.hibernate.LazyInitializationException: could not initialize proxy - no Session
       at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86)
       at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
       at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_4.getProcessDefinitionId(ExecutionImpl_$$_javassist_4.java)
       at org.jbpm.examples.processdefinition.id.ProcessDefinitionIdTest.testFindProcessDefinitionIdFromExecution(ProcessDefinitionIdTest.java:32)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at junit.framework.TestCase.runTest(TestCase.java:164)
       at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
       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 junit.framework.TestSuite.runTest(TestSuite.java:230)
       at junit.framework.TestSuite.run(TestSuite.java:225)
       at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
       at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
       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)
      ### EXCEPTION ###########################################