MySQL Forums
Forum List  »  InnoDB

MysqlXADataSource and Hibernate\JTA transaction: "insert into..." does not work in JBOSS 4.2.2!
Posted by: Massimiliano Magistri
Date: February 11, 2008 01:52PM

Hi everybody,

As You can easily understand from the email subject I am troubled
with Mysql\Jboss integration.

I use JBoss 4.2.2 and I access the MySql DB via a XA Datasource (com.mysql.jdbc.jdbc2.optional.MysqlXADataSource). I define the queries dinamically, accessing an Hibernate session through a Web Application deployed into JBoss.

In the following example I want to persist a "Request" object into the XA DS, via an hibernate\jta session.
To do this a call a "saveRequest()" method.

Every time I do a select against the XA DS everything goes as expected....as soon as I want to do an hibernate "saveRequest()" (which dinamically generates an Hibernate "insert" for the XA DS) I get back this fu__ing jboss exception:

(EVERY TIME I EXECUTE AN "INSERT" AGAINST THE XA MYSQL DS I GET BACK THIS:)

19:14:08,373 INFO [STDOUT] Hibernate:
insert
into
request
(request_date, contract_id)
values
(?, ?)
19:14:08,373 WARN [TxConnectionManager] Connection error occured: org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@1ae90c9[state=NORMAL mc=org.jboss.resource.adapter.jdbc.xa.XAManagedConnection@144719c handles=1 lastUse=1202753648227 permit=true trackByTx=true mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@1991ccf context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@1329346 xaResource=org.jboss.resource.connectionmanager.xa.JcaXAResourceWrapper@1a39fdc txSync=null]
java.lang.NullPointerException
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setDate(WrappedPreparedStatement.java:342)
...
at org.hibernate.type.DateType.set(DateType.java:44)
)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)
19:14:08,376 INFO [DateType] could not bind value '11 febbraio 2008' to parameter: 1; Error; - nested throwable: (java.lang.NullPointerException)
...
19:14:08,380 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
19:14:08,380 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
19:14:08,380 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
19:14:08,380 ERROR [STDERR] Caused by: java.lang.NullPointerException
19:14:08,380 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedStatement.internalClose(WrappedStatement.java:590)
19:14:08,380 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedStatement.close(WrappedStatement.java:75)
19:14:08,380 ERROR [STDERR] at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:534)
...
19:14:08,381 ERROR [STDERR] at com.prj.DataManager.saveRequest(DataManager.java:46)

19:14:08,412 ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
...
at java.lang.Thread.run(Unknown Source)
19:14:08,413 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@142b123
...
19:14:08,414 WARN [loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.rollbackxaerror] [com.arjuna.ats.internal.jta.resources.arjunacore.rollbackxaerror] XAResourceRecord.rollback - xa error [com.arjuna.ats.jta.utils.unknownerrorcode] Unknown error code:0
19:14:08,414 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_54] - Top-level abort of action a156303:e9ef:47b08fd5:65 received TwoPhaseOutcome.FINISH_ERROR from <ClassName:RecordType.JTA_RECORD>
19:14:08,415 ERROR [STDERR] javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
...
19:14:08,417 ERROR [STDERR] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)
19:14:08,417 ERROR [STDERR] ... 22 more
19:14:08,417 ERROR [[ReEvaluation]] Servlet.service() for servlet ReEvaluation threw exception
...
)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)

It's really weird because when a try to do the SAME "insert" manually the DBMS works properly.

I also tried to define the DATASOURCE as a <local-tx-datasource> and It worked as well!!!

Furthermore I made a Junit test which "locally" (without Jboss) persists the "request" object using the
same hibernate mappings and It does persist!

So...I think the issue is localized in the XA\Transaction Manager interaction....as u can see, everytime i avoid
this interaction everything goes right... it's weird, isnt' it?.... :O

I start to think that MysqlXADataSource.class in the Mysql .jar connector does not do his
dirty job properly....

I hope that somebody having the same Issue found out how to overcome it!

Please, answer me to: m.magistri@reply.it

Thank You anyway guys.

Massi

Options: ReplyQuote


Subject
Views
Written By
Posted
MysqlXADataSource and Hibernate\JTA transaction: "insert into..." does not work in JBOSS 4.2.2!
7498
February 11, 2008 01:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.