-
1. Re: jbpm console doesnt see process instance that was started by java
pmancham Jan 24, 2012 12:06 PM (in response to sebb)1 of 1 people found this helpfulI think you have to start the process from jbpm-console to see that in the reports.
If you just want history, then you have to enable persistence in your java app that is running processes.
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
// create a new knowledge session that uses JPA to store the runtime state
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
JPAWorkingMemoryDbLogger dblogger = new JPAWorkingMemoryDbLogger(ksession);
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);
ksession.getWorkItemManager().registerWorkItemHandler("myWorkItem", new MyWorkItemHandler());
int sessionId = ksession.getId();
ProcessInstance pi = (ProcessInstance) ksession.startProcess(processId);
System.out.println("Process started ... sessionId = " + sessionId + " processId = " + pi.getId());
logger.close();
dblogger.dispose();
ksession.dispose();
If you are using junit tests, then have a look at JBPMHelper.java in source code of jbpm5.2
-
2. Re: jbpm console doesnt see process instance that was started by java
sebb Jan 25, 2012 6:05 AM (in response to pmancham)Thanks, that helped a lot. I think the console should see processes from java code if I get the history log to work. I saw this quote in another thread:
Demian Calcaprina:
Jbpm console looks the processes in history logs databaseMaybe I can confirm this, but the history log still does not work. I added the code you mentioned and created a META-INF dir to place the persistence.xml I found in the documentation. Now I get another exception:
javax.naming.NameNotFoundException: unable to find a bound object at name 'jdbc/processInstanceDS'
Thats quite interesting since this object is used in the persistence.xml I used.
I add a screenshot of my workspace (plain jbpm installer 5.2 sample with modifications that are mentioned in this thread) so you can see what I could have done wrong.
-
3. Re: jbpm console doesnt see process instance that was started by java
pmancham Jan 25, 2012 12:45 PM (in response to sebb)1 of 1 people found this helpfulIf you are deploying in jboss AS7, then you have to make sure that
a) the datasource is defined in standalone.xml file
b) Use your own transaction manager lookup class (not BTMTransactionManagerLookup) in persistence.xml [Look at https://community.jboss.org/message/646526#646526]
-
4. Re: jbpm console doesnt see process instance that was started by java
pmancham Jan 25, 2012 12:57 PM (in response to pmancham)Setting up datasource in AS7: http://javalabor.blogspot.com/2011/08/oracle-datasource-in-jboss-as-7.html
-
5. Re: jbpm console doesnt see process instance that was started by java
pmancham Jan 25, 2012 1:00 PM (in response to pmancham)persistence.xml
<?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" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/jbpm-ds</jta-data-source>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<mapping-file>META-INF/Taskorm.xml</mapping-file>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>org.jbpm.process.audit.ProcessInstanceLog</class>
<class>org.jbpm.process.audit.NodeInstanceLog</class>
<class>org.jbpm.process.audit.VariableInstanceLog</class>
<class>org.jbpm.task.Attachment</class>
<class>org.jbpm.task.Content</class>
<class>org.jbpm.task.BooleanExpression</class>
<class>org.jbpm.task.Comment</class>
<class>org.jbpm.task.Deadline</class>
<class>org.jbpm.task.Comment</class>
<class>org.jbpm.task.Deadline</class>
<class>org.jbpm.task.Delegation</class>
<class>org.jbpm.task.Escalation</class>
<class>org.jbpm.task.Group</class>
<class>org.jbpm.task.I18NText</class>
<class>org.jbpm.task.Notification</class>
<class>org.jbpm.task.EmailNotification</class>
<class>org.jbpm.task.EmailNotificationHeader</class>
<class>org.jbpm.task.PeopleAssignments</class>
<class>org.jbpm.task.Reassignment</class>
<class>org.jbpm.task.Status</class>
<class>org.jbpm.task.Task</class>
<class>org.jbpm.task.TaskData</class>
<class>org.jbpm.task.SubTasksStrategy</class>
<class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
<class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
<class>org.jbpm.task.User</class>
<properties>
<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="edu.apollogrp.platform.jBpmUtil.MyTransactionManagerLookup"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
</properties>
</persistence-unit>
</persistence>
-
6. Re: jbpm console doesnt see process instance that was started by java
sebb Jan 26, 2012 5:55 AM (in response to pmancham)Thanks again for the answers.
I used your persistence.xml, created my own lookup class (which I referenced in your persistence.xml) and found the datasource in the standalone.xml (I had to remove the "-" in jbpm-ds), but it still doesnt work.
But I think I found the problem why it doesnt work:
Prasanth Manchambhatla schrieb:
If you are deploying in jboss AS7, then you have to make sure that
The jbpm console is deployed in AS7, but the code which starts the process engine is not. And I dont want to deploy it there either. So I think I have to add something to the persistence.xml that takes care of the remote part... I will look into it.