1 2 Previous Next 20 Replies Latest reply on Jan 12, 2007 1:42 AM by j_ri Go to original post
      • 15. Re: JTS on JBoss 4.0.5 with Oracle
        marklittle

         

        "j_ri" wrote:
        Hello qren,

        I must apologize that I ignored your posting after I read the follow up post:

        No, you should be able to involve the same backend datasource in different transactions concurrently.


        THIS IS NOT CORRECT.


        What do you mean by this is not correct? Are you trying to tell me that the same database cannot be involved in multiple transactions at the same time? If so, do you mean in general or in your application? I meant in general.


        If the second application uses a second datasource which points to a different database (on the same physical machine) everything works perfectly.
        If the second datasource only points to another schema on the same Oracle database the above mentioned errors happen.

        But what should I do now? Actually that's not really acceptable, because our architecture is based on the schemas.
        Ist that a problem of JBossTS or of the Oracle XADriver???


        A given Oracle db can be involved in multiple transactions at the same time. If you are seeing an error then there is something else going on.

        • 16. Re: JTS on JBoss 4.0.5 with Oracle
          j_ri

          Mark, you are talking of the same datasource which is backing two applications. But I have two datasources (with different users) pointing to the same database.

          Here are my datasource definitions:

          <xa-datasource>
          <jndi-name>jdbc/LPROFI_M01_LEGO_APPDS</jndi-name>
          <track-statements>true</track-statements>
          <track-connection-by-tx/>
          <isSameRM-override-value>false</isSameRM-override-value>
          <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
          <xa-datasource-property name="URL">jdbc:oracle:thin:@ORALPENTW:1527:ot27</xa-datasource-property>
          <xa-datasource-property name="User">LPROFI_M01_LEGO_APP</xa-datasource-property>
          <xa-datasource-property name="Password">XXXX</xa-datasource-property>
          <min-pool-size>1</min-pool-size>
          <max-pool-size>8</max-pool-size>
          <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
          <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
          <!-- Checks the Oracle error codes and messages for fatal errors -->
          <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
          <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
          <no-tx-separate-pools/>

          <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager

          </xa-datasource>


          <xa-datasource>
          <jndi-name>jdbc/LPROFI_M01_LIDOS_APPDS</jndi-name>
          <track-statements>true</track-statements>
          <track-connection-by-tx/>
          <isSameRM-override-value>false</isSameRM-override-value>
          <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
          <xa-datasource-property name="URL">jdbc:oracle:thin:@ORALPENTW:1527:ot27</xa-datasource-property>
          <xa-datasource-property name="User">LPROFI_M01_LIDOS_APP</xa-datasource-property>
          <xa-datasource-property name="Password">XXXX</xa-datasource-property>
          <min-pool-size>1</min-pool-size>
          <max-pool-size>8</max-pool-size>
          <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
          <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
          <!-- Checks the Oracle error codes and messages for fatal errors -->
          <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
          <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
          <no-tx-separate-pools/>

          <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager

          </xa-datasource>


          In this constellation my example is not working.
          But if I change the definition of one of the datasources to
          ...
          <xa-datasource-property name="URL">jdbc:oracle:thin:@ORALPENTW:1528:ot28</xa-datasource-property>
          ...
          the example is working. (ORALPENTW:1528:ot28 is a different database on the same physical machine holding a backup of all schemas)


          Our DB-Admin says that he could imagine that Oracle can gace two sessions in one transaction (and I think the second datasource opens a new session hence it has a different user).

          Perhaps qren (are you still reading this thread?) can confirm again and tell us what he tested?? Because I can't tell if that's a general problem or a special problem of my application.
          I can write two very simple demo applications for testing this issue next week in our environment. The applications I use at the moment are relative complex...

          • 17. Re: JTS on JBoss 4.0.5 with Oracle
            j_ri

            Hello,

            bad news for me;-)

            In my very trivial example JBossTS seems to work well. Tomorrow I'll do some more testing and place some "setRollbackOnly" in the code to see what happens.
            Then the next step will be to find out what's the problem with our "real" application.

            Can you give me a hint how to get the debug output of when the transactions start, prepare, etc.....

            I get much too much information from the driver...or no info....

            Thanks

            • 18. Re: JTS on JBoss 4.0.5 with Oracle
              j_ri

              I did some more testing and found out some more things:

              I built a new example which only uses plain jdbc via a jndi-datasource-lookup. In this example everything works perfectly. ejb1 writes something, and ejb2 on the other cluster-node reads it, then writes something to another datasource and all happens in the same transaction;-)

              But.....I can't get it to work, if I use Hibernate. As I said that it works with Hibernate some postings before I was wrong. There I didn't test if ejb2 can read the data written by ejb1 before. That didn't work. Only the 2-phase-commit worked.

              I could imagine that the mixed hibernate/plain-jdbc "architecture" I used (as explained in my preceding posts) so I did another test only using hibernate.
              The effect is that the ejb on node2 can't read the data written before by the other ejb on node1. So I think ejb1 and ejb2 are not in the same (global) transaction.
              So my conclusion is, that something is wrong with my hibernate configuration. Unfortunately I don't know what it is;-(
              I deployed hibernate in the jmx way as described in the HIbernate-3.2.0 documentation Chapter 3.8.4. Here is the jboss-service.xml used together with ejb1 (the descriptor for the SessionFactory used with ejb2 looks the same; just replace all "1" with "2"):

              <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>
               <attribute name="TransactionStrategy">org.hibernate.transaction.CMTTransactionFactory</attribute>
               <attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</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="JdbcBatchSize">20</attribute>
               <!-- Mapping files -->
               <attribute name="MapResources">.......</attribute>
              </mbean>
              </server>



              I did two tests with Hibernate:
              1.) First the .ear File on node1 has a HibernateSessionFactory configured on Datasource1 and the .ear on node2 has another HibernateSessionFactory configured on Datsource2. ejb2 wants to read what's written by ejb1 using a select over the Session from HibernateFactory2 (I granted the rights for selecting on the other datasource before).

              2.) First the .ear File on node1 has a HibernateSessionFactory configured on Datasource1 and the .ear on node2 has one HibernateSessionFactory configured on Datsource2 AND a HibernateSessionFactory configured on Datasource1 (for reading what was written before by the other ejb)

              In both configurations ejb2 on the second clusternode is not able to read what ejb1 has written before on the other node. Seems like two HibernateSessionFactories (or the Sessions I got from them) cannnot be in the same transaction.


              I created that file on basis of the example in the Hibernate Documentation that tells me to look into the JBoss documentation for further Details. But the JBoss Documentations doesn't explain how to deploy a Hibernate archive (.sar) that way (there a HAR-deployer is used);-(


              Any ideas what could be wrong with that setup? Is there a compatibility issue between Hibernate and JBossTS? Should I switch to the Hibernate-Forum with my problem?







              • 19. Re: JTS on JBoss 4.0.5 with Oracle
                marklittle

                I'd suggest posting to the Hibernate forum too.

                • 20. Re: JTS on JBoss 4.0.5 with Oracle
                  j_ri

                  O.k., here's the link:

                  http://forum.hibernate.org/viewtopic.php?t=969565

                  If anybody is still interested;-))

                  1 2 Previous Next