4 Replies Latest reply on Jun 3, 2009 10:35 AM by saurabhk.pixelsallover.s.gmail.com

    2 XA datasources USING JBoss

    saurabhk.pixelsallover.s.gmail.com

      I am a student working on Jboss with very basic knowledge of java. I was doing a project on Jboss to manage XA transactions using two data sources  I am very new to Jboss. I would be greatly obliged if anyone could help me how to go about it . I have to use two databases( Oracle, MSSQL, or may be My SQL ) . I am able to connect to the database one at a time using seam . But I have to configure to use the two databases simultaneously . So that if i do a trasaction then the results in the two databases have to be reflected.Just like a Bank transction(transfer of money) between two accounts of diferent banks. Please help me in going about it...


      ANy help will be great ..

        • 1. Re: 2 XA datasources USING JBoss
          gonorrhea

          from SiA book:



          Using distributed transactions in a Seam application
          One of the main reasons for using JTA transactions is to take advantage of distributed
          transactions. Despite Seam wrapping global transactions around each request,
          only the JTA implementation can support distributed transactions. In that case, you
          can work with multiple persistence managers and get two-phase commits as long as
          the underlying data source is configured as an XA resource. Chapter 14 (online) demonstrates
          how to set up XA data sources in the sample application.

          go here: http://www.manning.com/dallen


          Be advised that Oracle is XA-enabled out-of-the-box (not sure which version, but some co-workers told me this) and MSSQL is not...

          • 2. Re: 2 XA datasources USING JBoss
            saurabhk.pixelsallover.s.gmail.com

            Thanks, thanks so much ........


            please tell me wat do i need to do to  have XA-enabled  MSSQL.


            Do you know any more tutorials...

            • 3. Re: 2 XA datasources USING JBoss
              freakwave10

              Hi,


              you need to download the Mircrosoft jdbc 2.0 driver. (just google)


              Then you need to execute the xainstall.sql script that comes with the jdbc download package.
              Look at the end of the script to see how you add roles to your db user.

              Then configure the seam app

              1. create 2nd datasource entry in datasource (XA datasources) in the xxx-ds.xml
              2. create 2nd persistence unit in the persistence-dev.xml
              3. in the components.xml create the persistence manager context for both databases
              4. in the components.xml create the converters for both databases (important for html table to database record mapping)
              5. copy the sqljdbc.jar to the server/default/lib

              e.g. components.xml





              <persistence:managed-persistence-context auto-create="true" name="entityManager" persistence-unit-jndi-name="java:/AudioConferenceEntityManagerFactory" />
                      
                      <persistence:managed-persistence-context
                              auto-create="true" name="msSqlEntityManager" persistence-unit-jndi-name="java:/AudioConferenceEntityManagerFactoryMsSql" />
              
              
                      <ui:entity-converter name="standardEntityConverter" entity-loader="#{standardEntityLoader}" />
                      <ui:jpa-entity-loader name="standardEntityLoader" entity-manager="#{entityManager}" />
              
                      <ui:entity-converter name="msSqlEntityConverter" entity-loader="#{msSqlEntityLoader}" />
                      <ui:jpa-entity-loader name="msSqlEntityLoader" entity-manager="#{msSqlEntityManager}" />






                     


              Kind regards,


              Wolfgang

              • 4. Re: 2 XA datasources USING JBoss
                saurabhk.pixelsallover.s.gmail.com
                Hi Mr.Wolfgang Bergbauer

                I will explain you the problem in detail ... As i said earlier that I hav just started working on jboss(since last 20 days). I don't know much about it ..

                Let me explain how I am goin about it .

                First I am creating a Seam web project and establishing the conncetion with the oracle server and accesing the database in the oracle server ..
                Then I am making the changes in the ds.xml file, presistence.xml, components.xml of the seam project that I made which is connected to the oracle database(adding the Mssql details in the files) as you stated ..


                Is this the right approach to start??

                and when I am adding the statements

                <persistence:managed-persistence-context auto-create="true" name="msSqlEntityManager" persistence-unit-jndi-name="java:/EntityManagerFactoryMsSql" />
                  
                <ui:entity-converter name="msSqlEntityConverter" entity-loader="#{msSqlEntityLoader}" />
                <ui:jpa-entity-loader name="msSqlEntityLoader" entity-manager="#{msSqlEntityManager}" />
                   
                It gives an error :The prefix "ui" for element "ui:entity-converter" is not bound.

                Please let me know what to do

                Thanks in Advance