geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: XA_RBROLLBACK Exception when using Derby in transaction.roolback()
Date Wed, 11 Aug 2010 16:43:27 GMT
You should be able to use two datasources on one database.  It's a bit odd but we should be
able to handle it.  It's more plausible to get in this situation with a jms provider where
you have inbound and outbound messaging, geronimo will treat the inbound XAResource and outbound
XAResource as different.

It's possible that this is affected by whether what derby returns from isSameRM.  

I suspect this is from the second branch, derby is telling the tm that the tx has already
been rolled back from the first branch.

It would be a lot easier to investigate this if you could provide a complete exception stack
trace.

thanks!
david jencks

On Aug 11, 2010, at 8:30 AM, lilisacat wrote:

> I use
> DataSourceDefinition(name="java:app/SHAcc") link to url="jdbc:derby://localhost:1527/SHAcc",
> DataSourceDefinition(name="java:app/BJAcc")link to another url="jdbc:derby://localhost:1527/BJAcc",
> so they point to two different databases.
>     The transaction can commit correctly.
>  
>     The problem appears when I call the transaction.setRollBackOnly() method, transaction
will rollback in fact,
> but the server say: 
> org.apache.derby.client.am.XaException: XA_RBROLLBACK : Error executing a XAResource.end(),
server returned XA_RBROLLBACK
>  
> 2010-08-11
> lilisacat
> 发件人: sghayal
> 发送时间: 2010-08-11  21:03:11
> 收件人: dev
> 抄送:
> 主题: Re: XA_RBROLLBACK Exception when using Derby in transaction.roolback()
> 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.
> 
> From: "lilisacat" <lilisacat@gmail.com>
> Date: Wed, 11 Aug 2010 15:15:41 +0800
> To: dev<dev@geronimo.apache.org>
> ReplyTo: dev@geronimo.apache.org
> 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


Mime
View raw message