Version 4

    Using JBossTS with the Spring Framework

     

    The Spring framework (http://www.springframework.org) allows pluggable transaction managers. If you need XA support for your Spring application then you need to plug in a transaction manager such as JBossTS.

     

    Running inside JBossAS

     

    For use within the JBossAS application server (assuming it's running JBossTS already), you probably don't need to do anything. Just ensure your Spring application is configured to use

     

      <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    

     

    then the JtaTransactionManager will automatically find and use JBossTS via the application server's JNDI.

     

    JTA without an application server

     

    For standalone use, i.e. outside the application server, where you need JTA, the configuration is almost as easy:

     

      <bean id="jbossTransactionManager" class="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple">
      </bean>
    
      <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager">
          <ref bean="jbossTransactionManager"></ref>
        </property>
      </bean>
    

     

    You also need some additional elements in your classpath. Using ant format, these are:

     

      <path id="jbossts">
        <fileset dir="${jbossts.home}/lib">
          <include name="*.jar"></include>
        </fileset>
        <fileset dir="${jbossts.home}/lib/ext">
          <include name="*.jar"></include>
          <include name="*.zip"></include>
        </fileset>
        <pathelement location="${jbossts.home}/etc"></pathelement>
      </path>
    

     

    JTS (CORBA) Configuration

     

    If you are one of the people who need full JTS support outside the application server, there is a bit more work involved. Aside from a slightly different configuration in the .xml file and including the ORB classes on the classpath, you also need to call some setup methods in your code to correctly initialise JBossTS before performing any transactions.

     

    config:

     

      <bean id="jbossTransactionManager" class="com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple">
      </bean>
    
      <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager">
          <ref bean="jbossTransactionManager"></ref>
        </property>
      </bean>
    

     

    classpath:

     

      <path id="jbossts">
        <fileset dir="${jbossts.home}/lib">
          <include name="*.jar"></include>
        </fileset>
        <fileset dir="${jbossts.home}/lib/ext">
          <include name="*.jar"></include>
          <include name="*.zip"></include>
        </fileset>
        <pathelement location="${jbossts.home}/etc"></pathelement>
        <fileset dir="${jbossts.home}/jacorb/lib">
          <include name="*.jar"></include>
        </fileset>
      </path>
    

     

    setup code:

     

      com.arjuna.orbportability.ORB myORB = com.arjuna.orbportability.ORB.getInstance("ServerSide");
      com.arjuna.orbportability.RootOA myOA = com.arjuna.orbportability.OA.getRootOA(myORB);
      myORB.initORB(new String[] {}, null);
      myOA.initOA();
    

     

    Caveats

    The above guidelines assumes JBossTS 4.2.3.SP3 and Spring 2.0.5. However, neither this combination nor any other is officially supported at this time. That said, if you run into trouble try posting on the User Forum and we'll try to help out.

     

    Useful refs