[jboss-user] [jBPM] - Persistence and Transaction Management
Marco Piraccini
do-not-reply at jboss.com
Fri Jul 1 13:03:59 EDT 2011
Marco Piraccini [http://community.jboss.org/people/mpiraccini] created the discussion
"Persistence and Transaction Management"
To view the discussion, visit: http://community.jboss.org/message/613033#613033
--------------------------------------------------------------
Hi Guys,
I have a very strange behaviour with JBPM5.1 and the persistence.
I do not specify the TransactionManager in the Environment, but i set only the EntityManager. That seems to be correct, looking at the documentation (see 7.1.3 - Configuring Persistence).
My persistence unit is configured in that way:
<persistence-unit name="org.jbpm.persistence.jpa" transaction-type="RESOURCE_LOCAL">
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
<property name="hibernate.connection.username" value="xx" />
<property name="hibernate.connection.password" value="xx" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:test" />
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
The strange behaviour is that, when I try to run the code from a junit test using:
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
JPAKnowledgeService.newStatefulKnowledgeSession(knowledgeBase, getKnowledgeSessionConfiguration(),env);
I get this NPE:
18:39:06,775 ERROR [persistence.SingleSessionCommandService] Could not commit session
java.lang.NullPointerException
at org.drools.persistence.jta.JtaTransactionManager.getStatus(JtaTransactionManager.java:197)
at org.drools.persistence.jta.JtaTransactionManager.begin(JtaTransactionManager.java:150)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:120)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)
at org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:122)
There are some quite strange issues about that:
1) Why it uses the JtaTransactionManager even if the transaction-type is "RESOURCE_LOCAL"?
2) If I take a look at the JtaTransactionManager code, the NPE occurs because the UserTransaction is null. That's true, since no-one creates it! Indeed, looking at the SingleSessionCommandService method, the JtaTransactionManager is created in that way:
this.txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
tm );
...so, I have to specify the EnvironmentName.TRANSACTION to avoid the NPE? If so, why?
Thank you,
Marco.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/613033#613033]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110701/45f7aeb3/attachment.html
More information about the jboss-user
mailing list