[JBoss jBPM] - JTA Transaction support for jbpm - Issues with SeamPhaseList
by bloreguy
The issue here seems to be this:
I obtain a UserTransaction at the start of the method and in case of error, I call rollback in catch block. But the rollback is intercepted by the SeamPhaseListener which tries to begin a transaction and I get the error
" Could not start transaction:
org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:571"
How do I disable SeamPhaseListener from starting a new transaction?
More Details
---------------
I am having issues creating a new …
[View More]UserTransaction in a jbpm process using Hibernate. Am I missing anything in order to create a JTA User transaction and then bind the Hibernate session within the transaction? Please advise
Any advice greatly appreciated
My Code
-----------
public String createXXXXX()
{
JbpmContext jbpmContext = null;
Session session = null;
UserTransaction tx = null;
try
{
jbpmContext = JbpmUtil.getJbpmContext();
session = HibernateUtil.getSession();
jbpmContext.setSession(session);
System.out.println("About to start tx");
tx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
while ( ...) {
..... 1. Perform custom DB operations using session
2. Persist ProcessInstance, Task using the same session
// throw error to test rollback
}
} catch ( Exception e)
{
tx.rollback();
}
When Tx is rolled back, I expect that all DB operations and jbPM operations shoudl be rolled back. Instead I see this strange behavior:
When I lookup the transaction from InitialContext, the trasnaction statuis is already active!
**************** TX STATUS: 0
So, when I rollback the transaction I get the error:
java.lang.IllegalStateException: Could not start transaction
at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:571
)
at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(Se
amPhaseListener.java:307)
at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseList
ener.java:142)
at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.ja
va:116)
Caused by: javax.transaction.NotSupportedException: transaction is already active
at org.jboss.seam.transaction.HibernateTransaction.assertNotActive(Hiber
nateTransaction.java:174)
at org.jboss.seam.transaction.HibernateTransaction.begin(HibernateTransa
ction.java:78)
at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:566
jbpm.cfg.xml
---------------
<jbpm-configuration>
<jbpm-context>
< service name="persistence" >
< factory>
< bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
< field name="isTransactionEnabled"> < false/>
< field name="isCurrentSessionEnabled"> < false />
</ bean>
</ factory>
</ service>
< service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
< service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
< service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
< service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
< service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
</ jbpm-context>
</jbpm-configuration>
hibernate.cfg.xml
---------------------
<session-factory name="java:/bookingDatabase">
< property name="connection.datasource">java:/DefaultDS
< property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider
< property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory
< property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup
< property name="transaction.flush_before_completion">true
<!-- org.hibernate.transaction.JDBCTransactionFactory -->
< property name="jta.UserTransaction">java:comp/UserTransaction
< property name="hibernate.show_sql">true
<!-- Use the Hibernate built-in pool for tests. -->
< property name="connection.pool_size">1
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4140315#4140315
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4140315
[View Less]
16 years, 11 months