[JBoss jBPM] - UserTransaction issues with jBPM and Hibernate
by bloreguy
I am having issues creating a new 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=4138849#4138849
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4138849
18 years, 1 month
[Microcontainer] - Code example for a basic parsing deployer
by david.lloyd@jboss.com
Just wondering if there is a code example somewhere of a simple parsing deployer using the JAXB stuff. I'm having a hard time figuring out the intended usage based on the documentation (a lot of the deployer stuff is still missing from the docs it seems).
The documentation, in many cases, says things like "The BeanMetaData provides top level information and access to the more detailed information about the bean deployment" or "The purpose of Structure Deployer is to recognise the deployment type and prepare this information for the actual Deployers." These are all good, concise explanations for the purpose of these concepts. But then fails to explain how to actually use them in practice; e.g. I'm looking for something that says "To actually implement a deployer, extend XXX and provide implementations for YYY and ZZZ".
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138848#4138848
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4138848
18 years, 1 month