cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Transaction System Failure when using XA DataSource

Former Member
0 Likes
1,458

Hi,

I get "Transaction system failure" exception when I attempt to call for example an ejb method with SUPPORTS attribute set and right after calling an ejb method with transaction REQUIRED. This is happening XA Driver (on oracle). It does not seem to be working as designed :). I think the problem occurs in transactions after each time Datasource was used in a non-transactional context.

EnableLocalResourceInOTS is true.

To illustrate the problem please the test snippet below that is failing:

 public void testSupportsAndRequired() throws Exception {
        // calls an ejb method with SUPPORTS attr
        callEJBMethod1();
        // calls an ejb method with REQUIRED attr
        callEJBMethod2();
    }

Below is jdbc 2.0 section from data_sources.xml.

<jdbc-2.0>
        <xads-class-name>
          oracle.jdbc.xa.client.OracleXADataSource
        </xads-class-name>
        <properties>
          <property>
            <property-name>
              URL
            </property-name>
            <property-value>
              jdbc:oracle:thin:@app02:1521:VP40
            </property-value>
          </property>
          <property>
            <property-name>
              Password
            </property-name>
            <property-value encrypted="true">
              5e695d694c5c695d4b
            </property-value>
          </property>
          <property>
            <property-name>
              User
            </property-name>
            <property-value>
              vm32wip
            </property-value>
          </property>
        </properties>
      </jdbc-2.0>

View Entire Topic
Former Member
0 Likes

Hi Mikhail,

Could you please explain in details the scenario? Is it possible to provide us a test tool in order to simulate this strange behaviour?

Kind regards,

Andrei

Former Member
0 Likes

Hi Andrey,

To illustrate the actual idea I attached the following test stub. The intention was just to show the problem and

not to make a generic script to run as it would require an

EJB component too.

Running this test results in failures for

testSupportsAndRequired() and testRequired() method.

Regards,

Mikhail

package generic.ejb.miscellaneous.client;

import CertificationBO;
import CertificationBOHome;
import StatusBO;
import StatusBOHome;
import com.genrad.frame.BasicBOBeanException;
import com.genrad.frame.Data;
import com.genrad.frame.JNDIUtils;
import junit.framework.TestCase;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;

/**
 * User: MShapirov
 * Date: Mar 24, 2005
 */

public class GenericTransactionTest extends TestCase {

    InitialContext ctx;
    String host= "localhost";
    private int port = 50204;

    public GenericTransactionTest(String s) {
        super(s);
    }

    public GenericTransactionTest() {
        super("Transaction settings test");
    }


    protected void setUp() throws Exception {
        Hashtable props = new Hashtable();
        props.put(Context.INITIAL_CONTEXT_FACTORY, JNDIUtils.INITIAL_CTX_FACTORY);

        props.put(Context.PROVIDER_URL, host + ':' + port);
        ctx = new InitialContext(props);
    }

    public void testSupportsAndRequired() throws Exception {
        String output = callNonTransactionalMethod();
        System.out.println(output);
        output = callTransactionalMethod();
        System.out.println(output);
    }

    public void testSupports() throws Exception {
        String output = callNonTransactionalMethod();
        System.out.println(output);
    }

    public void testRequired() throws Exception {
        String output = callTransactionalMethod();
        System.out.println(output);
    }

    /**
     * statusEJB.getAllCodes has SUPPORTS attr
     * it also goes to database for data
     * @return
     * @throws com.genrad.frame.BasicBOBeanException
     */
    private String callNonTransactionalMethod() throws Exception {
        try {
            // Get a reference to the status bean
            StatusBOHome statusHome = (StatusBOHome) ctx.lookup("StatusBO");
            StatusBO statusEJB = statusHome.create();

            // Get all of the status codes from database
            statusEJB.getAllCodes("MIKH", "USER DEFINITION");
            return "sucess";
        } catch (BasicBOBeanException bbobe) {
            throw bbobe;
        }
    }

    /**
     * certificationEJB.dbRead has REQUIRED attr
     * it also goes to database for data
     * Returns the list of certifications available
     */
    private String callTransactionalMethod() throws Exception{
        try {

            // Get a reference to the certification bean
            CertificationBOHome certificationHome = (CertificationBOHome) ctx.lookup("CertificationBO");
            CertificationBO certificationEJB = certificationHome.create();

            // Get certifications from database
            // all certifications for that site
            certificationEJB.dbRead(new Data("SITE", "MIKH"));

            // Return the certification list
            return "success transactional method";
        } catch (BasicBOBeanException bbobe) {
            throw bbobe;
        }
    }

}