pvm_subprocess_problems
galanfish Feb 25, 2009 6:57 AMhi, can anyone help me:
there is a testcase 'org.jbpm.test.activities.SubProcessTest' in module 'test-pojo' which is run in object-mode.
and so i try to write a subprocess testcase running in persistent-mode. i have been trying but i can not make it... exception comes out:
10:37:11,250 SEV | [LazyInitializationException] could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at org.jbpm.pvm.internal.model.ActivityImpl$$EnhancerByCGLIB$$fa091528.getParentActivity(<generated>) at org.jbpm.pvm.internal.model.ExecutionImpl.initializeScopes(ExecutionImpl.java:210) at org.jbpm.pvm.internal.model.ExecutionImpl.start(ExecutionImpl.java:193) at org.jbpm.pvm.internal.model.ExecutionImpl.beginSubProcessInstance(ExecutionImpl.java:882) at name.galanfish.test.super_sub_process.cmd.StartSubProcessCmd.execute(StartSubProcessCmd.java:33) at name.galanfish.test.super_sub_process.cmd.StartSubProcessCmd.execute(StartSubProcessCmd.java:1) at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42) at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40) at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:52) at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.beginSubProcess(ExecutionServiceImpl.java:84) at name.galanfish.test.super_sub_process.SubProcess.execute(SubProcess.java:36) at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:57) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:587) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:560) at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:384) at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:62) at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:1) at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42) at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40) at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:52) at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:121) at name.galanfish.test.super_sub_process.SuperSubProcessTest.testSimpleSuperSubProcess(SuperSubProcessTest.java:38) 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 junit.framework.TestCase.runTest(TestCase.java:164) at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:81) 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.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:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
the source code as follow:
public class SuperSubProcessTest extends EnvironmentFactoryTestCase { private JbpmConfiguration factory; private ProcessServiceImpl processService; private ExecutionService executionService; @Override protected void setUp() throws Exception { super.setUp(); factory = (JbpmConfiguration) getEnvironmentFactory(); processService = (ProcessServiceImpl) factory.getProcessService(); executionService = factory.getExecutionService(); } public void testSimpleSuperSubProcess(){ createAndDeploySimpleSuperSubProcess(); executionService.startProcessInstanceById("super2:1", "superrequest8"); executionService.signalExecutionById("super2/superrequest8", "to_one"); } private void createAndDeploySimpleSuperSubProcess(){ ClientProcessDefinition superProcess = ProcessDefinitionBuilder.startProcess("super2") .startActivity("start", WaitState.class) .initial() .transition("one", "to_one") .endActivity() .startActivity("one", AutomaticActivity.class) .transition("sub", "to_sub") .endActivity() .startActivity("sub", SubProcess.class) .transition("end", "to_end") .endActivity() .startActivity("end", AutomaticActivity.class) .endActivity() .endProcess(); ClientProcessDefinition subProcess = ProcessDefinitionBuilder.startProcess("sub2") .startActivity("start", AutomaticActivity.class) .initial() .transition("end", "to_end") .endActivity() .startActivity("end", EndState.class) .endActivity() .endProcess(); deployProcess(superProcess); deployProcess(subProcess); } private void deployProcess(ProcessDefinition process){ Deployment deployment = processService.createDeployment(); deployment.addObject("process", process); processService.deploy(deployment); } } public class SubProcess implements ExternalActivityBehaviour{ private static final long serialVersionUID = 1L; public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception { } public void execute(ActivityExecution execution) throws Exception { ProcessService processService = Environment.getFromCurrent(ProcessService.class); ClientProcessDefinition subProcess = (ClientProcessDefinition)processService.findLatestProcessDefinitionByKey("sub2"); // hard code ExecutionService exeService = Environment.getFromCurrent(ExecutionService.class); // i add method 'beginSubProcess' in ExecutionService which is to execute the command 'StartSubProcessCmd'(source code as follow) Execution subExecution = exeService.beginSubProcess(execution, subProcess, "subrequest1"); // hard code if(!subExecution.isEnded()){ execution.waitForSignal(); } } } public class StartSubProcessCmd extends AbstractCommand<Execution>{ private static final long serialVersionUID = 1L; private ActivityExecution parentExecution; private ProcessDefinition subProcess; private String key; public StartSubProcessCmd(Execution parentExecution, ProcessDefinition subProcess, String key){ this.parentExecution = (ActivityExecution)parentExecution; this.subProcess = subProcess; this.key = key; } public Execution execute(Environment environment) throws Exception { ClientExecution subExecution = parentExecution.beginSubProcessInstance((ClientProcessDefinition) subProcess, key); return subExecution; } }
appreciate!