[Design of JBoss jBPM] - Re: Re-using the REST facade
by rmoskal
Just a quick followup, I was able to get the above tests to run by swapping out dotm for atomikos. And then by wrapping the test in a transaction template:
transactionTemplate = new TransactionTemplate((PlatformTransactionManager) applicationContext.getBean("transactionManager"));
ProcessInstanceRef proc = (ProcessInstanceRef) transactionTemplate.execute(new TransactionCallback() {
|
| public Object doInTransaction(TransactionStatus status) {
| ManagementFactory factory = ManagementFactory.newInstance();
| ProcessManagement service = factory.createProcessManagement();
| return service.getProcessInstance("Pipeline_3.one-shot11");
|
| }
| });
|
| assertNotNull(proc);
It would not work with dotm even with the transaction. I think the difference was the fact that atomikos has an XA data source.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4247413#4247413
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4247413
15 years, 5 months
[Design of JBoss jBPM] - Re: Re-using the REST facade
by rmoskal
I've gotten a bit farther so kindly ignore the last post. Using JOTM and the minimal spring JNDI implementation I bind the processEngine and the UserContext:
| SimpleNamingContextBuilder builder = new builder.bind("java:/ProcessEngine",
| builder.bind("UserTransaction", tx.getUserTransaction());
| builder.activate();
All my JPM interaction works fine when I work directly with the processEngine embedded in my Spring context. If I write I little unit test where I simply instantiate ProcessManagement and try to retrieve a list of deployed processes it works just fine:
ManagementFactory factory = ManagementFactory.newInstance();
| ProcessManagement service = factory.createProcessManagement();
| List<ProcessDefinitionRef> procs = service.getProcessDefinitions();
| assertNotNull(procs);
But if instead I try to get a deployed process like so:
ProcessInstanceRef proc = service.getProcessInstance("Pipeline_3.one-shot11");
| assertNotNull(proc);
I get an error in org.jboss.bpm.console.server.util.InvocationProxy, right at the line where the proxy method is invoked. Perhaps someone could tell me what might be different. The root exception says that "No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here". I don't see a big difference between the two methods in ProcessManagementImpl.
The stack trace follows:
java.lang.RuntimeException: Unexpected invocation exception: null
| at org.jboss.bpm.console.server.util.InvocationProxy.invoke(InvocationProxy.java:80)
| at $Proxy3.getProcessInstance(Unknown Source)
| at com.bluesky.skyline.workflow.integration.ConsoleIntegrationTest.testProcessDelpoy(ConsoleIntegrationTest.java:151)
| 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:168)
| at junit.framework.TestCase.runBare(TestCase.java:134)
| at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
| at junit.framework.TestResult$1.protect(TestResult.java:110)
| at junit.framework.TestResult.runProtected(TestResult.java:128)
| at junit.framework.TestResult.run(TestResult.java:113)
| at junit.framework.TestCase.run(TestCase.java:124)
| at junit.framework.TestSuite.runTest(TestSuite.java:232)
| at junit.framework.TestSuite.run(TestSuite.java:227)
| 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)
| Caused by: java.lang.reflect.InvocationTargetException
| 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 org.jboss.bpm.console.server.util.InvocationProxy.invoke(InvocationProxy.java:64)
| ... 22 more
| Caused by: org.jbpm.pvm.internal.wire.WireException: couldn't initialize object 'org.jbpm.pvm.internal.repository.RepositorySessionImpl': No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
| at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.initialize(ObjectDescriptor.java:233)
| at org.jbpm.pvm.internal.wire.WireContext.performInitialization(WireContext.java:537)
| at org.jbpm.pvm.internal.wire.WireContext.initialize(WireContext.java:499)
| at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:453)
| at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:441)
| at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:421)
| at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:331)
| at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:707)
| at org.jbpm.pvm.internal.env.BasicEnvironment.get(BasicEnvironment.java:151)
| at org.jbpm.pvm.internal.env.BasicEnvironment.get(BasicEnvironment.java:142)
| at org.jbpm.pvm.internal.env.Environment.getFromCurrent(Environment.java:200)
| at org.jbpm.pvm.internal.env.Environment.getFromCurrent(Environment.java:189)
| at org.jbpm.pvm.internal.model.ExecutionImpl.getProcessDefinition(ExecutionImpl.java:1096)
| at org.jbpm.integration.console.ModelAdaptor.adoptExecution(ModelAdaptor.java:69)
| at org.jbpm.integration.console.ProcessManagementImpl.getProcessInstance(ProcessManagementImpl.java:208)
| ... 27 more
| Caused by: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
| at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
| at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:622)
| at org.jbpm.pvm.internal.wire.descriptor.HibernateSessionDescriptor.construct(HibernateSessionDescriptor.java:73)
| at org.jbpm.pvm.internal.wire.WireContext.construct(WireContext.java:473)
| at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:452)
| at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:441)
| at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:421)
| at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:331)
| at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:707)
| at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.autoWire(ObjectDescriptor.java:294)
| at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.initialize(ObjectDescriptor.java:225)
| ... 41 more
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4247410#4247410
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4247410
15 years, 5 months
[Design of JBoss jBPM] - Re: Re-using the REST facade
by rmoskal
It is a bit more complicated. I forgot java chains constructors so I needed to touch the source for JBPMIntegration too. That and ProcessManagementImpl isn't a class public so I had to change that.
Making the above changes and loading the classes onto the spring context of my web application, got the REST api integrated into my application. All in all in took about an hour. However, I do see that I would have to do this with all the other plugins like form and graph. So I figure I'd better learn to love the jndi context again.
The integration this way is going pretty well. I just bind the processEngine on the Spring context to the jndi. I'm having some trouble understanding what the role of "UserTransaction" on the jndi context is.
tx = (UserTransaction)ctx.lookup("UserTransaction")
If I try to enumerate deployed processes for example I get a "javax.naming.NameNotFoundException: Name [UserTransaction] not bound" exception.
It seems that some of the integration code is dependendent on this. I think that if I deploy to jboss JBoss AS this is provided to me. I will test this. But what about if I want to deploy to tomcat or Jetty?
Any pointers would be greatly appreciated.
Thanks and regards,
Robert Moskal.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4247400#4247400
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4247400
15 years, 5 months