I am the developer of a JCA 1.5-compliant Resource Adapter which supports XA transactions.
I have a number of XA transaction tests that I have run successfully on several different Applications servers, including:
JBoss Application Server 4.0.5, 4.2.0, WebLogic Server 9.0, 10.0, WebSphere Application Server 6.0, and Sun System Java Application Server EE 8.2
Now I am trying to run the same tests on System Java Application Server EE 9.1 (Build b58g-fcs) and I have a test which is failing.
The test consists of a stateless session EJB (using EJB 2.0). This test uses a bean-managed transaction to insert some records into an Oracle database and call the Resource Adapter in the same XA transaction. For this particular test, the request to the Resource Adapter fails during the prepare phase so the transaction should be rolled back.
By the way, I'm using the following settings for my JDBC connection pool:
Datasource Classname: com.sun.sql.jdbcx.oracle.OracleDataSource
Resource Type: javax.sql.XADataSource
The test client does the following:
1) Call EJB preRunTest method
2) Call EJB runTest method
3) Call EJB postRunTest method
The preRunTest method does the following:
Delete all records from a database table
The runTest method does the following
UserTransaction.begin()
get Resource Adapter connection
Loop 3 times:
start loop
get database connection
create statement
execute "insert" statement
close statement
close database connection
end loop
Invoke the Resource Adapter
close Resource Adapter connection
UserTransaction.commit()
The postRunTest method does the following:
Delete all records from a database table
Record how many records were deleted
As expected, the call to UserTransaction.commit() fails and a roll back is initiated. However, the delete performed during the postRunTest method finds two records in the database, instead of zero as it expected (due to the rollback).
I modified the method runTest so that only one database connection is used. That is:
UserTransaction.begin()
get Resource Adapter connection
get database connection
create statement
Loop 3 times:
start loop
execute "insert" statement
end loop
close statement
close database connection
Invoke the Resource Adapter
close Resource Adapter connection
UserTransaction.commit()
When I ran the test this way, it worked as I expected: the portRunTest method found no records in the database, indicating that the rollback worked correctly.
[b]Shouldn't all of the database inserts be rolled back regardless of whether multiple database connections are used?[/b]
[Message sent by forum member 'burdeasa' (burdeasa)]
http://forums.java.net/jive/thread.jspa?messageID=249045