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.
so for the task server I have to send the following classes:
and for the the session I should only have the following:
That's right.. you also need the orm.xml file for the named queries. It should work.
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?
Are you sure that you update the source code from the repo recently? With what revision are you working on?
to get the latest modifications.
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.
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?
what's the problem that you have right now?
So we can help you to solve that specifically.
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();
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()
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.
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.
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.
Here is an example based on this discussion:
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 inhttp://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.
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.