cancel
Showing results for 
Search instead for 
Did you mean: 

Modifing userTask's formKey using Activit API

aigloss
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to modify the form key for a userTask using Activiti API. <!–break–>I've seen no method in FormService to achieve this, so, my first approach is to get the XML of the currently deployed process, add or modify the userTask "activiti:formKey" attribute, and redeploy it with the same name.
Lokks like it is correctly working, however, when it is done more than once, activiti engine seems to hang.
I've deployed an Activiti Explorer pointing to the same database, and I can see my deployment corerctly modify, but when I try to delete that deployment through Activiti Explorer, I have to reload the page myself to get it refreshed.

This is the code used for deploying:

DeploymentBuilder deploymentBuilder = new DeploymentBuilderImpl((RepositoryServiceImpl)this.processEngine.getRepositoryService());
deploymentBuilder.addInputStream(bpmnResourceName, new ByteArrayInputStream(getStringFromDocument(processDocument).getBytes()));
deploymentBuilder.name(processDefinition.getDiagramResourceName().substring(0,processDefinition.getDiagramResourceName().indexOf(".process.png")));
deploymentBuilder.deploy();


where getStringFromDocument(processDocument).getBytes()) returns the modified process XML. I've checked it out and it is returning exactly the same  as the original ".bpmn20.xml" file, but with the corresponding "activiti:formKey" added .
"bpmnResourceName" is the same name as original deployment; for example, "MyProcess.bpmn20.xml".
"processDefinition" is the processDefinition I'm trying to modify.

Been searching around the forum but haven't found any related topic..
Is it the correct approach? Is there any other approach to modify a task's formkey using Activiti API?


Thanks in advance.
6 REPLIES 6

trademak
Star Contributor
Star Contributor
What do you mean with "seems to hang"? Are you using the Activiti Explorer?
Adding a new version of the process definition like this is fine.

Best regards,

aigloss
Champ in-the-making
Champ in-the-making
Hi Tijs,

thanks for your quick response.
I'm currently using Spring to access the Process Engine. By "seems to hang" I mean I can keep using my app as long as what I try to use is not related to ProcesEngine. For example, if I try to query the database for current deployed processes, it is not responding, but I can navigate anywhere in my app that does nothing to do with ProcessEngine. Besides, when stopping Tomcat, it shows an error related to n query made by ProcessEngine to Process Definitions tables (have to kill the process since my app is not undeployed).

After doing a bunch of testing, I've find out that, when debugging the server, the problem is gone, so it looks like some kind of concurrency problem; so I'm refactoring my app to try get rid of it. (if you want, I can try to rollback my changes to get that error back and show it in this thread)

Anyway, is there any other way to change a task formkey than redeploying the whole process definition?

Thanks.

aigloss
Champ in-the-making
Champ in-the-making
The error in the log that "hangs" my app is back:
<em>
### The error may exist in org/activiti/db/mapping/entity/ProcessDefinition.xml
### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.selectProcessDefinitionsByQueryCriteria
### The error occurred while executing a query
### SQL: select * from ( select a.*, ROWNUM rnum from (     select RES.*              from ACT_RE_PROCDEF RES            WHERE  RES.VERSION_ = (select max(VERSION_) from ACT_RE_PROCDEF where KEY_ = RES.KEY_)           order by RES.ID_ asc        ) a where ROWNUM < ?) where rnum  >= ?]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
</em>
It is thrown in catalina.out when trying to redeploy my app. Any help would be appreciated.

trademak
Star Contributor
Star Contributor
Are you using an in-memory H2 database?

aigloss
Champ in-the-making
Champ in-the-making
No. I'm currently using Oracle 11.2.0.2.0 and Activiti 5.14.
The datasource is defined at server level and is used by some other apps, but none of them is having any problem with the database.

frederikherema1
Star Contributor
Star Contributor
The only way you can change the form-key is by deploying the process-definition again (effectively creating a new version of the process-definition, will not be applied for running versions) or manually update the database process-definition XML with the correct values (at own risk).
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.