-
1. Re: How to continue process in a web application
calca Jul 22, 2011 9:38 AM (in response to johnesky)Hi man, this should help:
StatefulKnowledgeSession session = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, config, env)
Demian
-
2. Re: How to continue process in a web application
johnesky Jul 22, 2011 10:24 AM (in response to calca)Thanks Demian. BUt how can I get the sessionId?
-
3. Re: How to continue process in a web application
calca Jul 22, 2011 10:29 AM (in response to johnesky)You may save it in a variable before disposing the session, for example after creating the session:
ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, environment);
int sessionId = ksession.getId();
-
4. Re: How to continue process in a web application
johnesky Jul 22, 2011 11:38 AM (in response to calca)Thanks Demian. I got this error using JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env ). What do you think I am doing wrong to get Java null pointer exception:
Exception in thread "main" java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:130)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)
at org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)
at com.sample.ProcessTest.main(ProcessTest.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)
... 3 more
Caused by: java.lang.RuntimeException: Could not commit session or rollback
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:133)
... 8 more
Caused by: java.lang.RuntimeException: Unable to rollback transaction
at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:184)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:131)
... 8 more
Caused by: java.lang.NullPointerException
at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:181)
... 9 more
Here is part of my code below:
KnowledgeBase kbase = readKnowledgeBase();
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "org.jbpm.task" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
ksession.startProcess("com.sample.bpmn.hello");
Thanks again for your time.
-
5. Re: How to continue process in a web application
calca Jul 22, 2011 12:01 PM (in response to johnesky)Try with
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("org.jbpm.persistence.jpa");
"org.jbpm.task" should be used to construct your task service, not to create the session (for example, https://github.com/calcacuervo/JBPM5-Samples/blob/master/human-tasks/src/test/java/com/test/BaseHumanTaskTest.java)
Demian
-
7. Re: How to continue process in a web application
garytse Jul 25, 2011 3:21 AM (in response to johnesky)>>>
Caused by: java.lang.RuntimeException: Unable to rollback transaction
at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:184)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:131)
... 8 more
Caused by: java.lang.NullPointerException
at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:181)
... 9 more
<<<
My guess, is that you're trying to run it outside a J2EE container; it doesnt work. (see https://issues.jboss.org/browse/JBPM-3282)
Otherwise, double check the persistence.xml file
-
8. Re: How to continue process in a web application
johnesky Jul 25, 2011 11:14 AM (in response to johnesky)Gary thanks for replying, but the thread wasn't helpful.
Thanks a lot Demian, it was a perfect example for me. Through the example I was able to run the application as a desktop applicaton, and it worked perfectly fine and persisted to my postgres database. But when I decided to run the same application as a web application with tomcat 6.0 for deployment, then I get this error and do you know why:
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [org.drools.persistence.info.SessionInfo]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)
at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:478)
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:193)
at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)
at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:167)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:127)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)
at org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:174)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.
at org.postgresql.largeobject.LargeObjectManager.createLO(LargeObjectManager.java:241)
at org.postgresql.largeobject.LargeObjectManager.createLO(LargeObjectManager.java:228)
at org.postgresql.jdbc2.AbstractJdbc2Statement.setBlob(AbstractJdbc2Statement.java:2817)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:181)
at org.hibernate.type.ByteArrayBlobType.set(ByteArrayBlobType.java:106)
at org.hibernate.type.AbstractLobType.nullSafeSet(AbstractLobType.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2025)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2271)
... 41 more
Jul 25, 2011 10:09:46 AM org.drools.persistence.jta.JtaTransactionManager commit
WARNING: Unable to commit transaction
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [org.drools.persistence.info.SessionInfo]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:513)
at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:478)
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:193)
at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)
at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:167)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:127)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)
at org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:174)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [org.drools.persistence.info.SessionInfo]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)
... 31 more
Caused by: org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.
at org.postgresql.largeobject.LargeObjectManager.createLO(LargeObjectManager.java:241)
at org.postgresql.largeobject.LargeObjectManager.createLO(LargeObjectManager.java:228)
at org.postgresql.jdbc2.AbstractJdbc2Statement.setBlob(AbstractJdbc2Statement.java:2817)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:181)
at org.hibernate.type.ByteArrayBlobType.set(ByteArrayBlobType.java:106)
at org.hibernate.type.AbstractLobType.nullSafeSet(AbstractLobType.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2025)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2271)
... 41 more
-
9. Re: How to continue process in a web application
calca Jul 25, 2011 11:18 AM (in response to johnesky)It seems to be related with transaction configuration, in which the UserTransaction is not being created. I configured it following these:
http://community.jboss.org/people/bpmn2user/blog/2011/02/26/orcale-integration-with-jbpm5
And worked.
If is does not work, please attach some test that shows your persistence/transaction configuration.
Regards,
Demian
-
10. Re: How to continue process in a web application
calca Jul 25, 2011 12:03 PM (in response to calca)Did you configure your tomcat with Bitronix, like the link http://community.jboss.org/people/bpmn2user/blog/2011/02/26/orcale-integration-with-jbpm5 ?
-
11. Re: How to continue process in a web application
johnesky Jul 25, 2011 12:16 PM (in response to calca)yes I did.
-
12. Re: How to continue process in a web application
johnesky Jul 25, 2011 5:29 PM (in response to johnesky)Hi Demian, I got it solved now. I had to set Hibernate autocomit to false. Thanks for your time, really appreciate it. I just can't get the process to continue in another JSP page which is frustrating. When I run the other jsp page to continue the process it clears all data in the task table. And also, the sessioninfo table isn't persisting. What do you think I may be doing wrong?
-
13. Re: How to continue process in a web application
mariemm Jul 26, 2011 2:08 AM (in response to johnesky)Don't have you
<property name="hibernate.hbm2ddl.auto" value="create"/> in persistence.xml?
-
14. Re: How to continue process in a web application
johnesky Jul 26, 2011 12:10 PM (in response to mariemm)Thanks Marie. But create is also doing the same. I had create-drop before.