U r using wrong url. Both the url point to same database. This is what seems to be happening. A single transaction has been started which is being committed twice.
If using xa u need two physically different databases. Hope this helps. Cheers, Sandip Sent from my “contract free” BlackBerry® smartphone on the WIND network. -----Original Message----- From: "lilisacat" <[email protected]> Date: Wed, 11 Aug 2010 15:15:41 To: dev<[email protected]> Reply-To: [email protected] Subject: XA_RBROLLBACK Exception when using Derby in transaction.roolback() Hi, I encournter a problem when run the app in the G-3.0-SANPSHOT. In the app, I used Datasource DS-A and Datasource DS-B to link two derby database. If UserTransaction.rollback() called, the server occured error: org.apache.derby.client.am.XaException: XA_RBROLLBACK : Error executing a XAResource.end(), server returned XA_RBROLLBACK. Here is the details of two Datasource: //DataSourceSH @DataSourceDefinition(name="java:app/SHAcc", className="org.apache.derby.jdbc.ClientXADataSource", url="jdbc:derby://localhost:1527/SHAcc", user="system", databaseName="SHAcc", transactional=true, maxPoolSize=10, properties = {"createDatabase = create"}) //DataSourceBJ @DataSourceDefinition(name="java:app/BJAcc", className="org.apache.derby.jdbc.ClientXADataSource", url="jdbc:derby://localhost:1527/BJAcc", user="system", databaseName="BJAcc", transactional=true, maxPoolSize=10, properties = {"createDatabase = create"}) In the Servlet, I used two datasources as following: Context initContext = new InitialContext(); tx = (UserTransaction)initContext.lookup("java:comp/UserTransaction"); // Start a transaction // First, use DataSourceSH ds = (javax.sql.DataSource) initContext.lookup("java:app/SHAcc"); //get connection with database: SHAcc //do some update on database: SHAcc if(failFlag) {tx.setRollBackOnly();} // Second, use DataSourceBJ ds = (javax.sql.DataSource) initContext.lookup("java:app/BJAcc"); //get connection with database: BJAcc //do some update on database: BJAcc // commit all the operations tx.commit(); } catch(Exception e){ if(tx!=null){ try{ // rollback the operations tx.rollback(); System.out.println("catch: roll back success.");} catch(Exception e1){ System.out.println("catch: roll back fail.");} } System.out.println("catch: " + e.getClass() + "; " + e.getMessage()+""); }...... I have no idea why Error executing a XAResource.end() if tx.rollback() happens? Thanks ! 2010-08-11 Lisa
