I have created a small process which has one script task. In this task, I call one method of a personal Java class. Then this method updates an existing line in an Oracle database and commit.
As my table is located in the same schema of the one owning the jBPM persistence tables, in my Java class I use the PoolingDataSource returned by JBPMHelper.setupDataSource().
But, when I run my process, I have an error saying:
java.sql.SQLException: cannot commit a resource enlisted in a global transaction
As I configured my jBPM engine to persist the data, I imagine that there is a transaction while my script task executes. That's why I can not to the commit.
So I am wondering how I should in fact design such a behaviour:
1) Should I first put my own tables into an Oracle schema different that the one used by jBPM to persist? I think yes.
2) According to what I read in the documentation, I should also use a Service task instead of a script task as a database access can be long, with timeouts...
3) Can I reuse in my own Java code the PoolingDataSource returned by JBPMHelper.setupDataSource()? I assume that I should not, and particularly if I put my tables in another schema.
4) If I write a service task to write in database, how should I design this task? I mean, should I reuse hibernate and the persistence.xml file for that? Can I do basic JDBC accesses? What are the best practices usually applied for such situation?
5) It is not clear at all in my mind when a transaction starts and stops in a jBPM process. What are the safe points? Could you basically explain?
Thanks a lot.