-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: distributed transaction in jboss cluster
PostPosted: Thu Jan 11, 2007 11:53 am 
Newbie

Joined: Thu Jan 11, 2007 9:16 am
Posts: 2
After Reading a lot within the Forums here and at jboss.org I finally ask the question here in this forum.

I have an issue using hibernate in a clustered JBoss environment (JBoss 4.0.5GA, JBossTS JTS 4.2.2GA, Oracle 10g with Driver 10.2.0.2). I have two cluster nodes and each node has running a stateless session bean.

1.) node1 inserts data to datasource1
2.) node1 calls node2
3.) node2 (should) read the data persisted by node1
4.) node2 inserts data to datasource2

Unfortunately this scenario doesn't work. In step 3 the ejb on node2 is not able to read the data which was written by the ejb on node1;-(
There is no Exception; the reading from the datasource works...there's just an empty result.

To get this to work I tried the following Hibernate configuration:
The .ear file on node1 defines one SessionFactoryMBean pointing to datasource1.
The .ear file on node2 defines 2 SessionFactoryMBeans; one pointing to datsource1 for reading the data written by ejb1 and another pointing to datasource2 for persisting other data.
The datasources point to different schemas on the same Oracle database.


2-Phase-Commit between the two datasources works (both ejb can write their data, just the read bewteen returns nothing), but it's not a real distributed transaction.

My cluster and JBossTS setup should be correct. I created the same example using plain jdbc via the jndi-looked-up-datasources...and this works perfectly as expected.

I deployed Hibernate as a .sar file within the .ear as described in the Hibernate-3.2.0 documentation Chapter 3.8.4.
And I tried with "org.hibernate.transaction.CMTTransactionFactory" and "org.hibernate.transaction.JTATransactionFactory":

Code:
<server>
   <mbean code="org.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,name=XATestNode2HibernateSessionFactory">
      <attribute name="Datasource">
         java:jdbc/XATestNode2_DS
      </attribute>
      <!-- Bind the Hibernate service to JNDI -->
      <attribute name="JndiName">
         XATestNode2HibernateSessionFactory
      </attribute>
      <!-- Transaction integration -->
      <attribute name="TransactionStrategy">
         org.hibernate.transaction.CMTTransactionFactory
      </attribute>
      <attribute name="TransactionManagerLookupStrategy">
         org.hibernate.transaction.JBossTransactionManagerLookup
      </attribute>
      <attribute name="FlushBeforeCompletionEnabled">true</attribute>
      <attribute name="AutoCloseSessionEnabled">true</attribute>
      <attribute name="Dialect">
         org.hibernate.dialect.Oracle9Dialect
      </attribute>
      <attribute name="SecondLevelCacheEnabled">false</attribute>
      <attribute name="CacheProviderClass">
         org.hibernate.cache.NoCacheProvider
      </attribute>
      <attribute name="QueryCacheEnabled">false</attribute>
      <attribute name="JdbcFetchSize">20</attribute>
      <attribute name="BatchVersionedDataEnabled">false</attribute>
      <!--        <attribute name="StreamsForBinaryEnabled">true</attribute> -->
      <attribute name="JdbcBatchSize">20</attribute>
      <attribute name="ShowSqlEnabled">true</attribute>
      <!-- Mapping files -->
      <attribute name="MapResources">
         de/lbank/xatestnode2/hibernate/Node2TestData.hbm.xml
      </attribute>
   </mbean>
</server>



In my code I use "sessionFactory.getCurrentSession().persist(xxx)" to get my session.
As datasource I use a XA-Datasource with the Oracle thin driver (which works well in my plain jdbc example)


Are two SessionFactories (on different Cluster Nodes) not able to return sessions for the same distributed transaction? Or is there a mistake in my configuration?

After three days of reading and testing I feel quite frustrated. So help would be very much appreciated;-)

Thanks
Jochen


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 10:07 am 
Newbie

Joined: Thu Jan 11, 2007 9:16 am
Posts: 2
I solved it.

Since I have disabled the second level cache I have to flush() before I can call another clusternode that tries to read the data again......

Can I give credits to myself now?;-))


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.