db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johan Hoogenboezem" <hooge...@worldonline.co.za>
Subject RE: Derby XA, Hibernate 2.1.6, WebSphere 5.1 - Server returned XAER_NOTA at commit time
Date Wed, 21 Sep 2005 05:03:09 GMT
Hi Stanley
Thank you for responding.
I don't know how to do what you ask, though. By the nature of the message
driven bean in which context the code runs I do not and should not know
about any open transactions. The container starts the transaction, Hibernate
senses it is running inside a container transaction (through the way it is
configured) and defers all transaction handling to the container. The only
thing I'm allowed to do is to call setRollbackOnly() in case I handle a
checked exception and decide a rollback is in order. I cannot begin, end or
commit a transaction without getting an error thrown at me by the container.
Unless I decouple my persistence code from the container, which I don't want
to do, because then I don't have distributed transactions anymore. 
Everything seems ok if XA is not involved. In other words if I have a
stateless session bean with container managed transactions that do not
involved messaging or any other XA participants, then I happily do creates,
reads, updates and deletes through Derby.

I assume Derby does cleanup as a result of some event and that perhaps it
should be moved to a different event in case of an XA tranasction? Sorry if
I re-state the obvious. I'm amazed at how often, once I've fixed an error, I
notice that the exception's been telling me what was wrong all along.

Here's the onMessage() method of my MDB:
================================================start
  public void onMessage(javax.jms.Message msg) {
    try {
      if (msg.getJMSRedelivered()) { // needs to be looked at in more
detail.
        L.debug("Message was redelivered. Not reprocessing it.");
        return;
      }
 
getServiceLocator().getUpdatesDispatcher().dispatch((ObjectMessage)msg);
    }
    catch (Exception ex) {
      L.error("Error", ex);
      L.debug("setting rollback");
      context.setRollbackOnly();
      // Display the error but swallow it. We don't want the message bean to
die
    }
    finally {
      BaseDomainAccessHibernate.closeCurrentSession();
    }
  }
================================================end
Inside the updates dispatcher I have code that gets the current hibernate
session from a ThreadLocal (creating it if not present) for doing database
updates. 
This is what it looks like (it uses the singleton
net.sf.hibernate.SessionFactory instance and currentSession is the
ThreadLocal):
================================================start
  public static Session getCurrentSession() 
    throws HibernateException {
    Session s = (Session)currentSession.get();
    if (s == null) {
      s = getSessionFactory().openSession();
      currentSession.set(s);
    }
    return s;
  }
================================================end

And then the closing if the current session is done like this:

================================================start
  public static void closeCurrentSession() {
    Session s = (Session)currentSession.get();
    if (s != null) {
      try {
        s.flush();
        s.close();
      }
      catch (HibernateException e) {
        processStandardHibernateException(e);
      }
      finally {
        currentSession.set(null);
      }
    }
  }
================================================end

I've been looking at some of the Hibernate code, and it defers to the
container for transaction handling, as it should.
Please let me know if there is anything else I can do.
This is important as I want my whole team to convert to Derby for
development.
Regards
Johan


-----Original Message-----
From: Stanley Bradbury [mailto:Stan.Bradbury@gmail.com] 
Sent: Tuesday, September 20, 2005 4:19 PM
To: Derby Discussion
Subject: Re: Derby XA, Hibernate 2.1.6, WebSphere 5.1 - Server returned
XAER_NOTA at commit time


Hi Johan -
I will be able to look into this error more later today but wanted to 
get this observation to you ASAP since this issue seems to have set for 
a week.  The root cause of the failure is this exception taken from one 
of the repeated stack traces from the MCWrapper class:

original exception message: Cannot call 'cleanup' on a ManagedConnection
while it is
still in a transaction..

Based on this message I recommend placing a check in your code to insure 
there are no open transactions prior to calling cleanup.  I can't 
explain why this would be an issue when Derby is used and not DB2 but I 
am hoping it is as simple as doing a check and handling all open 
transactions.

Johan Hoogenboezem wrote:

>Hi,
>I'm using Derby 10.1.1.0 with derbyclient in a WebSphere 5.1 server
>environment. Here's the first part of the console output that shows some
>versioning info:
>
>***************************************************************************
*
>**Start
>WebSphere Platform 5.1 [BASE 5.1.0.3 cf30412.02] [JDK 1.4.1 b0344.02]
>running with process name localhost\localhost\server1 and process id 2304
>Host Operating System is Windows XP, version 5.1
>Java version = J2RE 1.4.1 IBM Windows 32 build cn1411-20031011 (JIT
enabled:
>jitc), Java Compiler = jitc, Java VM name = Classic VM
>...
>...
>***************************************************************************
*
>**End
>
>I've set up a data source using org.apache.derby.jdbc.ClientXADataSource.
>Hibernate is configured as follows:
>
>***************************************************************************
*
>**Start
>hibernate.connection.datasource = java:comp/env/jdbc/DefaultDS
>hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransac
t
>ionFactory
>hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.Web
S
>phereTransactionManagerLookup
>hibernate.dialect=net.sf.hibernate.dialect.DB2Dialect
>hibernate.connection.username=APP
>hibernate.connection.password=APP
>hibernate.show_sql=false
>***************************************************************************
*
>**End
>
>I get the current session from a ThreadLocal variable, so that in the
>context of the current thread, anything asking for a hibernate session will
>get the same session. I'm using Stateless Session Beans and Message Driven
>Beans. Specifically in this instance I'm using an MDB with WebSphere MQ as
>the JMS implementation. The transaction is managed by the container and in
a
>finally clause inside the onMessage() method I call a closeCurrentSession()
>utility method that just flushes and closes the hibernate session stored in
>the ThreadLocal.
>
>Everything works fine when using a datasource for DB2. However, when I
>switch to Derby, I get this:
>
>***************************************************************************
*
>**Start
>[9/13/05 8:23:49:819 CAT] 1e59f386 WSRdbXaResour E DSRA0304E:  XAException
>occurred. XAException contents and details are: The cause is
:
>org.apache.derby.client.am.SqlException: Error executing a
>XAResource.commit(), Server returned XAER_NOTA.
>
>[9/13/05 8:23:49:819 CAT] 1e59f386 WSRdbXaResour E DSRA0302E:  XAException
>occurred.  Error code is: XAER_NOTA.  Exception is: XAER_NOTA : Error
>executing a XAResource.commit(), Server returned XAER_NOTA
>
>[9/13/05 8:23:49:889 CAT] 1e59f386 XATransaction E J2CA0027E: An exception
>occurred while invoking commit on an XA Resource Adapter from dataSource
>jdbc/derby/scvwebdev, within transaction ID {XID: formatId(57415344),
>gtrid_length(39), bqual_length(28),
>data(0000000000000002000000044c4c40cbd49eaa1530e4b7146f080d8853876c7a736572
7
>66572314c4c40cbd49eaa1530e4b7146f080d8853876c7a000000048333bb35)}:
>org.apache.derby.client.am.XaException: XAER_NOTA : Error executing a
>XAResource.commit(), Server returned XAER_NOTA
>	at
>org.apache.derby.client.net.NetXAResource.throwXAException(Unknown Source)
>	at org.apache.derby.client.net.NetXAResource.commit(Unknown Source)
>	at
>com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.commit(WSRdbXaResourceImpl.jav
a
>:182)
>	at
>com.ibm.ejs.j2c.XATransactionWrapper.commit(XATransactionWrapper.java:432)
>	at
>com.ibm.ws.Transaction.JTA.JTAXAResourceImpl.commit(JTAXAResourceImpl.java:
2
>42)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredResources.distributeOutcome(Registered
R
>esources.java:1044)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredResources.distributeCommit(RegisteredR
e
>sources.java:1555)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.internalCommit(TransactionImpl.j
a
>va:1432)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1012
)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:150)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:182)
>	at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:712)
>	at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:167)
>	at
>com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.ja
v
>a:565)
>	at
>com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3038)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:102)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
>	at
>com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:372)
>	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
>Caused by: org.apache.derby.client.am.SqlException: Error executing a
>XAResource.commit(), Server returned XAER_NOTA
>	at
>org.apache.derby.client.net.NetXAResource.xaRetValErrorAccumSQL(Unknown
>Source)
>	... 18 more
>.
>
>[9/13/05 8:23:50:039 CAT] 1e59f386 MCWrapper     E J2CA0081E: Method
cleanup
>failed while trying to execute method cleanup on ManagedConnection
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl@30083383 from resource
>jdbc/derby/scvwebdev. Caught exception: com.ibm.ws.exception.WsException:
>DSRA0080E: An exception was received by the Data Store Adapter. See
original
>exception message: Cannot call 'cleanup' on a ManagedConnection while it is
>still in a transaction..
>	at
>com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreA
d
>apterException.java:217)
>	at
>com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreA
d
>apterException.java:171)
>	at
>com.ibm.ws.rsadapter.AdapterUtil.createDataStoreAdapterException(AdapterUti
l
>.java:208)
>	at
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions(WSR
d
>bManagedConnectionImpl.java:2508)
>	at
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanup(WSRdbManagedCon
n
>ectionImpl.java:2243)
>	at com.ibm.ejs.j2c.MCWrapper.cleanup(MCWrapper.java:1177)
>	at
>com.ibm.ejs.j2c.poolmanager.FreePool.returnToFreePool(FreePool.java:292)
>	at
>com.ibm.ejs.j2c.poolmanager.PoolManager.release(PoolManager.java:1251)
>	at
>com.ibm.ejs.j2c.MCWrapper.releaseToPoolManager(MCWrapper.java:1684)
>	at
>com.ibm.ejs.j2c.XATransactionWrapper.afterCompletionCode(XATransactionWrapp
e
>r.java:359)
>	at
>com.ibm.ejs.j2c.XATransactionWrapper.afterCompletion(XATransactionWrapper.j
a
>va:300)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeAfter(RegisteredSyncs.
j
>ava:161)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.distributeAfter(TransactionImpl.
j
>ava:2344)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredResources.distributeCommit(RegisteredR
e
>sources.java:1567)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.internalCommit(TransactionImpl.j
a
>va:1432)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1012
)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:150)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:182)
>	at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:712)
>	at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:167)
>	at
>com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.ja
v
>a:565)
>	at
>com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3038)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:102)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
>	at
>com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:372)
>	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
>
>
>[9/13/05 8:23:50:290 CAT] 1e59f386 WSRdbManagedC W DSRA0180W: Exception
>detected during ManagedConnection.destroy().  The exception is:
>com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by
>the Data Store Adapter. See original exception message: Cannot call
>'cleanup' on a ManagedConnection while it is still in a transaction..
>	at
>com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreA
d
>apterException.java:217)
>	at
>com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreA
d
>apterException.java:171)
>	at
>com.ibm.ws.rsadapter.AdapterUtil.createDataStoreAdapterException(AdapterUti
l
>.java:208)
>	at
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions(WSR
d
>bManagedConnectionImpl.java:2508)
>	at
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.destroy(WSRdbManagedCon
n
>ectionImpl.java:1966)
>	at com.ibm.ejs.j2c.MCWrapper.destroy(MCWrapper.java:1327)
>	at
>com.ibm.ejs.j2c.poolmanager.FreePool.returnToFreePool(FreePool.java:305)
>	at
>com.ibm.ejs.j2c.poolmanager.PoolManager.release(PoolManager.java:1251)
>	at
>com.ibm.ejs.j2c.MCWrapper.releaseToPoolManager(MCWrapper.java:1684)
>	at
>com.ibm.ejs.j2c.XATransactionWrapper.afterCompletionCode(XATransactionWrapp
e
>r.java:359)
>	at
>com.ibm.ejs.j2c.XATransactionWrapper.afterCompletion(XATransactionWrapper.j
a
>va:300)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeAfter(RegisteredSyncs.
j
>ava:161)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.distributeAfter(TransactionImpl.
j
>ava:2344)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredResources.distributeCommit(RegisteredR
e
>sources.java:1567)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.internalCommit(TransactionImpl.j
a
>va:1432)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1012
)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:150)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:182)
>	at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:712)
>	at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:167)
>	at
>com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.ja
v
>a:565)
>	at
>com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3038)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:102)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
>	at
>com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:372)
>	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
>.
>
>[9/13/05 8:23:50:340 CAT] 1e59f386 MCWrapper     E J2CA0081E: Method
destroy
>failed while trying to execute method destroy on ManagedConnection
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl@30083383 from resource
>No longer available. Caught exception: com.ibm.ws.exception.WsException:
>DSRA0080E: An exception was received by the Data Store Adapter. See
original
>exception message: Cannot call 'cleanup' on a ManagedConnection while it is
>still in a transaction..
>	at
>com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreA
d
>apterException.java:217)
>	at
>com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreA
d
>apterException.java:171)
>	at
>com.ibm.ws.rsadapter.AdapterUtil.createDataStoreAdapterException(AdapterUti
l
>.java:208)
>	at
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions(WSR
d
>bManagedConnectionImpl.java:2508)
>	at
>com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.destroy(WSRdbManagedCon
n
>ectionImpl.java:1966)
>	at com.ibm.ejs.j2c.MCWrapper.destroy(MCWrapper.java:1327)
>	at
>com.ibm.ejs.j2c.poolmanager.FreePool.returnToFreePool(FreePool.java:305)
>	at
>com.ibm.ejs.j2c.poolmanager.PoolManager.release(PoolManager.java:1251)
>	at
>com.ibm.ejs.j2c.MCWrapper.releaseToPoolManager(MCWrapper.java:1684)
>	at
>com.ibm.ejs.j2c.XATransactionWrapper.afterCompletionCode(XATransactionWrapp
e
>r.java:359)
>	at
>com.ibm.ejs.j2c.XATransactionWrapper.afterCompletion(XATransactionWrapper.j
a
>va:300)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeAfter(RegisteredSyncs.
j
>ava:161)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.distributeAfter(TransactionImpl.
j
>ava:2344)
>	at
>com.ibm.ws.Transaction.JTA.RegisteredResources.distributeCommit(RegisteredR
e
>sources.java:1567)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.internalCommit(TransactionImpl.j
a
>va:1432)
>	at
>com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1012
)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:150)
>	at
>com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:182)
>	at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:712)
>	at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:167)
>	at
>com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.ja
v
>a:565)
>	at
>com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3038)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:102)
>	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
>	at
>com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:372)
>	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
>***************************************************************************
*
>**End
>
>Any help with this will be greatly appreciated. I'm in the process of
>converting all my team members to Derby, so this is a real show-stopper for
>us.
>
>Regards
>Johan Hoogenboezem
>IZAZI Solutions (Pty) Limited | 57 6th Road | Hyde Park | Johannesburg |
>South Africa
>tel: + 27 11 788 0333 | mobile: +27 83 296 2360 | fax: + 27 11 788 2630
>e-mail: johanh@izazi.com | web: www.izazi.com 
>DISCLAIMER This message is intended for the addressee only, as it contains
>information that is privileged, private and confidential. If you are not
the
>intended recipient of this message, you are notified that any distribution,
>use or copying of this communication is strictly prohibited. If you have
>received this communication in error, please notify the sender immediately
>
>
>
>  
>





Mime
View raw message