tags:

views:

130

answers:

1

Hi. I have a strange behaviour going on.

I am using Seam and JBPM. When I say:

ProcessDefinition templateDefinition = Jbpm.instance().getProcessDefinitionFromResource(ap.getJpdl()); 
//This will return Enkeltanledning.jpdl.xml
templateDefinition.getVersion();

It always returns -1. However, when I select from the database, I get version 2.

mysql> select * from JBPM_PROCESSDEFINITION;
+-----+--------+-----------------------------+--------------+----------+------------------------+-------------+
| ID_ | CLASS_ | NAME_                       | DESCRIPTION_ | VERSION_ | ISTERMINATIONIMPLICIT_ | STARTSTATE_ |
+-----+--------+-----------------------------+--------------+----------+------------------------+-------------+
|   1 | P      | Enkeltanledning             | NULL         |        1 |                        |           1 | 
|   2 | P      | Enkeltanledning             | NULL         |        2 |                        |          31 | 

Now, I found this link: jpdl And it says:

Unnamed process definitions will always have version number -1.

However, I have my process definitions are not unnamed, and when I debug templateDefinition I get the correct name Enkeltanledning ,so I know it is the correct jpdl file that has been loaded.

So my question is, why does my code always return -1 in version? The reason why I need the version to be correct, is because I am doing some checks to see if I have the correct version, otherwize I will redeploy the ProcessDefinition, and since I always get -1, it will always redeploy.

A: 

I found the answer.

Its because I am reading the ProcessDefinition from the file instead of quering the database. Changing the code to this solved it

@In
JbpmContext jbpmContext;

ProcessDefinition templateDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition(processDefName);
Shervin