PDA

View Full Version : help!jbpm3.1 about spring


gavinfiredrake
May 10th, 2006, 04:34 AM
add two method :

public ProcessDefinition loadProcessDefinition(final long id){

return (ProcessDefinition) execute(new JbpmCallback() {

public Object doInJbpm(JbpmContext context) {
return context.getGraphSession().loadProcessDefinition(id );
}
});
}


public void saveTaskInstance(final TaskInstance taskinstance){

execute(new JbpmCallback() {

public Object doInJbpm(JbpmContext context) {
context.save(taskinstance);
return null;
}
});
}


************************************************** *******
test case:

public void testStartProcessInstance() {

ProcessDefinition processDefinition = m_template.loadProcessDefinition(1);
ProcessInstance instance = processDefinition.createProcessInstance();


}


*********************************************
error
@APPNAME@] ERROR [main] LazyInitializationException.<init>(19) | could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initia lize(AbstractLazyInitializer.java:56)
at org.hibernate.proxy.AbstractLazyInitializer.getImp lementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept (CGLIBLazyInitializer.java:158)
at org.jbpm.graph.def.ProcessDefinition$$EnhancerByCG LIB$$4c3f3edf.createProcessInstance(<generated>)
at com.kingsoft.workflow.test.SpringTestDb.testStartP rocessInstance(SpringTestDb.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154 )
at junit.framework.TestCase.runBare(TestCase.java:127 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)

Costin Leau
May 10th, 2006, 05:02 AM
You have lazy loading exceptions - a very common problem. See the jbpm module from Spring modules (from your stacktrace I see that you are not using it). It combines the hibernate support in Spring with Spring - see the test cases for more information.

gavinfiredrake
May 10th, 2006, 08:32 PM
thank you for you reply! i have seen your jbpm module ! i only add two mothod in JbpmTemplate.java!
i want to test start process! i think other people will make same error!
if you make complete test example ,i real thank you!
1: start process
2:find task
3: finish task
thank you!

gavinfiredrake
May 10th, 2006, 08:42 PM
can you point out my error place!:confused:

Costin Leau
May 12th, 2006, 02:59 PM
The Hibernate connection is not closed - see the AbstractTransactional tests from the mock package inside Spring. They are used also inside jBPM tests to create transactions and keep Hibernate sessions opened during tests.