-
1. TaskServer, persistence file and session
salaboy21 Feb 20, 2011 4:20 PM (in response to odelyaholiday)Hi there,
You are actually questioning about persistence here. The exampleapp configure 2 different persistence unit for two different reasons,Session Info and Processes Info. if you want, you can merge them bothand just use one. but for real applications having the tasksinformation and the runtime information separated can help you to scalebetter.
greetings
-
2. TaskServer, persistence file and session
odelyaholiday Feb 21, 2011 5:38 AM (in response to salaboy21)so for the task server I have to send the following classes:
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<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>
and for the the session I should only have the following:
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
-
3. TaskServer, persistence file and session
salaboy21 Feb 21, 2011 6:25 AM (in response to odelyaholiday)That's right.. you also need the orm.xml file for the named queries. It should work.
-
4. TaskServer, persistence file and session
odelyaholiday Feb 28, 2011 5:52 AM (in response to salaboy21)I saw that the orm.xml file under EmergencyDemo is not updated. it was missing ProcessInstancesWaitingForEvent.
Where is the location of the most updated file?
-
5. TaskServer, persistence file and session
salaboy21 Feb 28, 2011 6:28 AM (in response to odelyaholiday)Are you sure that you update the source code from the repo recently? With what revision are you working on?
Try with:
git pull
to get the latest modifications.
Greetings
-
6. TaskServer, persistence file and session
odelyaholiday Feb 28, 2011 6:41 AM (in response to salaboy21)See the file here:
it's missing ProcessInstancesWaitingForEvent query
-
7. TaskServer, persistence file and session
salaboy21 Feb 28, 2011 6:53 AM (in response to odelyaholiday)You're totally right.. I will fix that asap.
I was working on a local branch to add persistence support for the app.
That orm.xml file is for the task related queries. And it's an exact copy of the file located inside the jbpm-human-task module. If you look in the jbpm5 source code you will find a different orm.xml file containg the ProcessInstancesWaitingForEvent query. That file can be located under the the *-persistence-jpa module. Check: https://github.com/krisv/jbpm/blob/master/jbpm-persistence-jpa/src/test/resources/META-INF/orm.xml
If you merge both files you can just have one orm.xml file.
Greetings.
-
8. TaskServer, persistence file and session
mariemm Mar 10, 2011 10:51 AM (in response to salaboy21)I was trying to create simple example which will save both the process info (and log) and the task info. I have the examples for saving them separately but I am not able to make it work together.
Is there any example available?
Thank you.
-
9. TaskServer, persistence file and session
salaboy21 Mar 10, 2011 10:54 AM (in response to mariemm)what's the problem that you have right now?
So we can help you to solve that specifically.
Greetings.
-
10. Re: TaskServer, persistence file and session
mariemm Mar 16, 2011 6:16 AM (in response to salaboy21)Ok, I will try one error now:
I changed the example Simple emergency to be able save process info in DB, with ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, config, env );
This is OK, it saves all data as expected.
Then I added the task service (based on another HelloProcess example):
TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
TaskServiceSession taskSession = taskService.createSession();
taskSession.addUser(new User("Admin"));
taskSession.addUser(new User("kris"));
When I run the test, it stops in taskSession.addUser(new User("Admin")); with
A JTA EntityManager cannot use getTransaction()
java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)
at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)
at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:707)
at org.jbpm.task.service.TaskServiceSession.persistInTransaction(TaskServiceSession.java:682)
at org.jbpm.task.service.TaskServiceSession.addUser(TaskServiceSession.java:69)
at com.wordpress.salaboy.examples.ProcessTaskTest.humanTasksTest(ProcessTaskTest.java:83)
I tried several different ways to get rid of it, nothing worked. I am using persistence unit with all classes together. See persistence.xml in attachment.
Do you have any idea about this exception? Thank you a lot for your time.
-
ProcessTaskTest.zip 2.2 KB
-
persistence.zip 1.0 KB
-
-
11. Re: TaskServer, persistence file and session
salaboy21 Mar 11, 2011 8:24 AM (in response to mariemm)I'm downloading your sources to see what's happening. I will take a look on it later today, please ping me later to see if I have time to see it.
Thanks for modifying the sample project to use persistence. I will include that in one of the next modules of the training.
Greetings
-
12. Re: TaskServer, persistence file and session
mariemm Mar 16, 2011 6:24 AM (in response to salaboy21)I found solution for me. It didn't work with one entity manager factory, but I managed to make it work with two.
Persistence.xml has in both persistence units (nearly) all classes because I use one orm.xml which merges all queries. In code I have following:
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );
EntityManagerFactory emfTask = Persistence.createEntityManagerFactory( "org.jbpm.myTask" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
env.set( EnvironmentName.GLOBALS, new MapGlobalResolver() );
TaskService taskService = new TaskService(emfTask, SystemEventListenerFactory.getSystemEventListener());
I don't understand exactly why the persistence unit for process and for task are different.
If anyone makes it running with one persistence, let me know.
-
13. Re: TaskServer, persistence file and session
bpmn2user Mar 26, 2011 11:10 PM (in response to mariemm)Here is an example based on this discussion:
http://community.jboss.org/people/bpmn2user/blog/2011/03/25/jbpm5--persistence-hello-process-example
Marie MM,
You seem to use both the persistence units (process and task) from the same example.
Did you get the exception '
Could not commit session
' as discussed in
http://community.jboss.org/thread/163990?tstart=0.?Did you configure UserTransaction?
The example shown in http://community.jboss.org/people/bpmn2user/blog/2011/03/25/jbpm5--persistence-hello-process-example uses two different persistence units and human task server is started independently.
-
14. TaskServer, persistence file and session
mariemm Mar 28, 2011 12:16 PM (in response to bpmn2user)Hi, thanks for example.
Do you know why there is the reduncancy in classess used in persistence units, in persistence.xml? There many classes used in both persistence units. It works for me and for now, so I am happy with it, but sooner or later someone from my company will ask me "why".
Ad "Could not commit session": I had many exceptions ..., but I don't remember this one. Actually, I didn't play with the transactions yet.