you can use the method
import org.jbpm.workflow.instance.WorkflowProcessInstance; WorkflowProcessInstance processInstance=(WorkflowProcessInstance)ksession.startProcess("processId"); Collection<NodeInstance> currentNodeInstances=processInstance.getNodeInstances();
in collection currentNodeInstances you'll find all active nodes of processInstance!
I have answered your question?
a more basic question is why do you need that?
We usually try to avoid doing that...
For reporting, I would like to list all process instances that I have and which status it has, along with "where" (node) they are stopped.
Do you suggest another way of doing this?
Why do you usually avoid it?
If you enable persistence and BAM feature as explain in user guide (http://docs.jboss.org/jbpm/v5.1/userguide/ch07.html#d0e2836) you can query your database to retrieve all NodeInstanceLog that has an entry with type = 0 but not his related entry with type = 1.
Nice!! I've read the ch07 but I could not find examples on how to retrieve the ProcessInstanceLog/NodeInstanceLog objects. Can you please provide examples?
You can use the EntityManagerFactory that you put in the Enviroment to create a SteatefulKnowledgeSession to get an EntityManager and create a query like
SELECT n FROM org.jbpm.process.audit.NodeInstanceLog WHERE ...
You can check how it is used in console:
Or for example this test:
Basically, you create a logger to save information in bam tables:
and then you can use a
JPAProcessInstanceDbLog processLog = new JPAProcessInstanceDbLog(session.getEnvironment());
to get the information with its methods:
I usually recommend to use the history logs or a custom processEventListner to find out that information. Using the java apis will probably not give you enough flexibility to have a query mechanism for all the situations.
I'm trying to follow the path indicated by Demian (save and retrieve information from BAM tables) but I simply can not make persistence work.
I get this exception where I try to excute the following junit test :
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
// Construct DataSource
JdbcDataSource ds = new org.h2.jdbcx.JdbcDataSource();
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"));
env.set( EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager() );
session = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
... 33 more
Caused by: java.lang.RuntimeException: Could not commit session or rollback
... 38 more
Caused by: java.lang.RuntimeException: Unable to rollback transaction
... 39 more
Caused by: java.lang.NullPointerException
Please find attached my persistence.xml file
What am I missing?
persistence.xml 1.4 KB
I am not sure which transaction-type is default, but could you try adding transaction-type="JTA" to your persistence.xml?
I also haven't no idea!
maybe if you are in a Java Standard Edition environment you should set also the TransactionManager in environment and then handle the transaction boundary your self as explain in user guide (http://docs.jboss.org/jbpm/v5.1/userguide/ch07.html#d0e2820). Instead if you are in Java Enterprise Edition i haven't any suggestion...
I have used bitronix 1.3.3 in SE!
Of course your problem is related to transactions....