jBPM - XA transaction
ranendas Apr 14, 2010 1:31 PMHello,
I want to do Xa transaction with jBPM and another Datasource of my application. Both cases, I am using only Hibernate, no spring.
I started with UserTransaction, then started normal hibernate operation, here DS for Normal Hibertane is XA and JTA is the transaction mode and I am using Weblogic 10 AS.
Now my normal Hibernate transaction using JTA is working fine, but jBPM part is not working fine, I can commit both the DS together, but if there is any exception in my Normal DS, jBPM still commits which is WRONG. I stringly believe I made a mistake somewhere in jBPM configuration. Can anyone tell me where am I wrong?
Here is my code base :-
jbpm.cfg.xml
< jbpm-configuration> <!-- The default configurations can be found in org/jbpm/default.jbpm.cfg.xml Those configurations can be overwritten by putting this file called jbpm.cfg.xml on the root of the classpath and put in the customized values. --> <jbpm-context> <service name="persistence"> <factory> <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory"> <field name="isTransactionEnabled"><false /></field> <field name="isCurrentSessionEnabled"><true /></field> <field name="sessionFactoryJndiName"> <string value="java:/myHibSessFactJndiName" /> </field> <!--<field name="sessionFactoryJndiName">java:/myHibSessFactJndiName</field>--> </bean> </factory> </service> </jbpm-context> <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" /> </jbpm-configuration> hibernate.cfg.xml file <? ?> <! PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" > < > > <!-- hibernate dialect --> > > > > > > > @TransactionAttribute(TransactionAttributeType.SUPPORTS) HibernateConfig objHbCfg = null; if(objHbCfg !=null){ OfferPo offerPo= new OfferPo(); jbpmContext = jbpmConfiguration.createJbpmContext(); Regards, Ranen Regards, Ranen
public void doXATransWithHiber()
{
try{
tx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
tx.begin();
objHbCfg = OfferHibernateUtil.getHibernateConfig(OfferServiceConstant.OFFER_DOMAIN);
Session session1 = null;
session1 = objHbCfg.currentSession(HibernateConfigType.OFFER);
}
Long offerId= new Long(2574);
Criteria crit = session1.createCriteria(OfferPo.class);
crit.add(Restrictions.eq("offerId", offerId));
offerPo = (OfferPo) crit.list().get(0);
String processId = offerPo.getOfferProcessId();
offerPo.setOfferId(offerId);
offerPo.setOfferName("NewTest_XA_13thApril_2-0");
session1.persist(offerPo);
SessionFactory sessfac = (SessionFactory)new InitialContext().lookup("java:/myHibSessFactJndiName");
jbpmContext.setSession(sessfac.getCurrentSession());
long processInstanceId = 126694;
ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
processInstance.signal();
jbpmContext.save(processInstance);
tx.commit();
}catch(Exception e)
{
e.printStackTrace();
try{
if(tx !=null){
tx.rollback();
}
}catch(Exception sqle)
{
sqle.printStackTrace();
}
} finally{
jbpmContext.close();
}
}
Regards,
Ranen
Regards,
Ranen
Regards,
Ranen
Regards,
Ranen