-
1. Re: jBPM processes started from Java code dont show up in jBPM process console
calca Nov 28, 2011 7:05 PM (in response to prakashp5562)Hey,
How are you starting the process from java code? Could you please paste the code you are using?
Jbpm console looks the processes in history logs database (http://docs.jboss.org/jbpm/v5.1/userguide/ch07.html#d0e2836)
So make sure you are attaching the logger to the ksession:
JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);Hope this helps
Demian
-
2. Re: jBPM processes started from Java code dont show up in jBPM process console
prakashp5562 Nov 29, 2011 10:24 AM (in response to calca)Thanks Demian.
I added the JPAWorkingMemoryDBLogger along with the persistence.xml, but sill not showing up in the process console.
The process is started w/o exceptions as I can see the user tasks in the process console, but not the process instances.
Below is my code.
private void StartWorkflow( String messageToPublish, String Identifier, String tag )
{
try
{
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
JPAWorkingMemoryDbLogger dbLogger = new JPAWorkingMemoryDbLogger(ksession);
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
//start a new process instance
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());
// start a new process instance
Map<String, Object> params = new HashMap<String, Object>();
params.put("reason", "Registration");
params.put("patientXml", messageToPublish);
params.put("identifier", Identifier);
params.put("tag", tag);
ksession.addEventListener(new com.ge.edadmit.rest.RegistrationEventListener());
ksession.startProcess("com.ge.edadmit.EdAdmitWorkflow", params);
dbLogger.dispose();
//dblogger.
logger.close();
}
catch (Throwable t)
{
System.out.println(t.getMessage());
t.printStackTrace();
}
}
-
3. Re: jBPM processes started from Java code dont show up in jBPM process console
calca Nov 29, 2011 10:35 AM (in response to prakashp5562)mmm
do you have in your persistence.xml ProcessInstanceLog, NodeInstanceLog and VariableInstanceLog mapped?
Do do you see information about your processes in these tables in database?
Demian
-
4. Re: jBPM processes started from Java code dont show up in jBPM process console
prakashp5562 Nov 29, 2011 10:54 AM (in response to calca)Below is the persistence.xml & the tables in the database. Is this the right database
Which tables should I look for.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
version="1.0"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.jbpm.persistence.jpa">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/processInstanceDS</jta-data-source>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.jbpm.persistence.processinstance.WorkItemInfo</class>
<class>org.jbpm.process.audit.ProcessInstanceLog</class>
<class>org.jbpm.process.audit.NodeInstanceLog</class>
<class>org.jbpm.process.audit.VariableInstanceLog</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
</properties>
</persistence-unit>
</persistence>
-
5. Re: jBPM processes started from Java code dont show up in jBPM process console
jsolanu Nov 29, 2011 10:56 AM (in response to calca)I'm pretty much having the same issue, downloaded today from http://sourceforge.net/projects/jbpm/files/latest/download?source=files
Ran the demo setup and script referenced on http://docs.jboss.org/jbpm/v5.1/userguide/ch03.html
Tried to run the example in section 3.4 of the user guid and nothing shows up under the Process Instances, Process Instance, or Human Task View in eclipse, though they are listed in the console discussed in section 3.5.
-
6. Re: jBPM processes started from Java code dont show up in jBPM process console
calca Nov 29, 2011 10:59 AM (in response to prakashp5562)I cannot see the image, it is small..
Do you see the processes you started from java doc in ProcessInstanceLog table?
-
7. Re: jBPM processes started from Java code dont show up in jBPM process console
prakashp5562 Nov 29, 2011 12:21 PM (in response to calca)Sorry but I dont see the ProcessInstanceLog table.
I opened Hypersonic query analyzer & see all JBM tables, no JBPM tables are seen
-
8. Re: jBPM processes started from Java code dont show up in jBPM process console
calca Nov 29, 2011 12:23 PM (in response to prakashp5562)How is your connection string to h2?
-
9. Re: jBPM processes started from Java code dont show up in jBPM process console
prakashp5562 Nov 29, 2011 12:39 PM (in response to calca)I did not do anything specific.
whats by default.
-
10. Re: jBPM processes started from Java code dont show up in jBPM process console
prakashp5562 Nov 29, 2011 12:59 PM (in response to calca)from my hsqldb-ds.xml, the connection url is
<connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB</connection-url>
But this db does not have any JBPM tables.
-
11. Re: jBPM processes started from Java code dont show up in jBPM process console
swiderski.maciej Dec 2, 2011 9:27 AM (in response to prakashp5562)Console is retrieving process instances from history tables using jbpm-bam module. It is configured via hibernate.cfg.xml. So it can be either inside jbpm-bam-{version}.jar file or in gwt-console-server.war file. It contains connection definition to the data base to retrieve history information.
So you could verify that it has right data, by default it uses H2 db instead of hsql.
HTH
-
12. Re: jBPM processes started from Java code dont show up in jBPM process console
mbraud Jan 15, 2012 9:33 AM (in response to prakashp5562)Hi
I've got a similar issue except that in my case, processes started from java simply reset entries in my database.
I have only one process available. The first step in this process is a human task.
If I start 2 process instances from the jBPM console, both process instances appear in the "Process Overview" tab and they also appear in the database (I'm persisting PROCESSINSTANCEINFO, PROCESSINSTANCELOG, SESSIONINFO, VARIABLEINSTANCELOG, WORKITEMINFO and NODEINSTANCELOG in a H2 DB).
If I start the same process from the java code, my 2 previous process instances disappear (both from the console and the database which is consistent) and get replaced by the new process instance.
If I start another process instance from the java code, it replaces the previous one so that I can never have more than 2 process instances started from my java code.
Here is my java code:
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());
env.set( EnvironmentName.GLOBALS, new MapGlobalResolver() );
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(ACCESS_WORKFLOW_FILE), ResourceType.BPMN2 );
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
JPAWorkingMemoryDbLogger dbLogger = new JPAWorkingMemoryDbLogger(ksession);
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));
ksession.startProcess(ACCESS_WORKFLOW_ID, new HashMap());
dbLogger.dispose();
logger.close();
Also I forgot to mention it but I'm deploying jBPM 5.1 on Tomcat 6 and I'm not using Guvnor but simply a directory specified in "-Djbpm.console.directory".
I've also noted some strange behaviour where my process instances also seem to be reset everytime I restart tomcat. The entries remain in the DB after I shutdown Tomcat and they also remain in it once I've restarted Tomcat and logged in the jBPM console again but the moment I go to the "Process Overview" tab and jBPM reloads the process definition, all process instances disappear from my DB.
I think that I'm missing something important here but I don't know what.
Any help would be greatly appreciated
Maïté
-
13. Re: jBPM processes started from Java code dont show up in jBPM process console
swiderski.maciej Jan 15, 2012 11:06 AM (in response to mbraud)Most likely your persistence.xml file has property hibernate.hbm2ddl.auto set to create or create-drop which means that whenever you build EntityManagerFactory will reset your data base by rebuilding schema. Change that to update and your problem will disappear (in all described cases).
HTH
-
14. Re: jBPM processes started from Java code dont show up in jBPM process console
mbraud Jan 16, 2012 5:22 AM (in response to swiderski.maciej)Of course, the Hibernate settings! I should have thought about that really...
Yep, that solved the problem.
Thanks a lot for the help and sorry for the trivial question.
Maïté