[jboss-user] [jBPM] - jBPM - XA transaction

Ranendra Das do-not-reply at jboss.com
Wed Apr 14 13:34:07 EDT 2010


Ranendra Das [http://community.jboss.org/people/ranendas] created the discussion

"jBPM - XA transaction"

To view the discussion, visit: http://community.jboss.org/message/537478#537478

--------------------------------------------------------------
Hello,

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



<?


xml version='1.0' encoding='utf-8'?>

<!


DOCTYPE hibernate-configuration PUBLIC



"-//Hibernate/Hibernate Configuration DTD 3.0//EN"



"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<


hibernate-configuration>


<session-factory>



<!-- hibernate dialect -->


<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>


<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>


<property name="hibernate.connection.datasource">jdbc/JbpmDataSource</property>



<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>


<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>


<property name="jta.UserTransaction">java:comp/UserTransaction</property>


<property name="hibernate.current_session_context_class">jta</property>








 @TransactionAttribute(TransactionAttributeType.SUPPORTS)
   public void doXATransWithHiber()
   {
  try{
  tx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
  tx.begin();
  HibernateConfig objHbCfg = null;
  objHbCfg = OfferHibernateUtil.getHibernateConfig(OfferServiceConstant.OFFER_DOMAIN);
  Session session1 = null;
  if(objHbCfg !=null){
   session1 = objHbCfg.currentSession(HibernateConfigType.OFFER);
  }
  OfferPo offerPo= new OfferPo();
  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);
  jbpmContext = jbpmConfiguration.createJbpmContext();
  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












 Regards,
Ranen











 Regards,
Ranen













































































--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/537478#537478]

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/20100414/f94af6f2/attachment.html 


More information about the jboss-user mailing list