Creating XA Datasource in JBoss 7.1.1 for MySQL Cluster : Connection Read Only Error
Posted by: Manjunatha Nakshathri
Date: December 17, 2013 02:49AM

We are configuring the XA datasource in the JBoss 7.1.1 application server for the backend clustered MySQL server (Master-Master configuration). Below are the datasource configuration:

<xa-datasource jndi-name="java:/datasoucrenew" pool-name="datasoucrenew" enabled="true" use-ccm="false">
<xa-datasource-property name="URL">
jdbc:mysql://10.27.40.35:3306,10.27.40.36:3306/fwcms_cdc_prod?autoReconnect=true
</xa-datasource-property>
<xa-datasource-property name="password">
password
</xa-datasource-property>
<xa-datasource-property name="user">
user
</xa-datasource-property>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<driver>mysql-connector-java-5.1.12-bin.jar</driver>
<xa-pool>
<min-pool-size>0</min-pool-size>
<max-pool-size>100</max-pool-size>
<use-strict-min>true</use-strict-min>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter"/>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
We are facing below issues:

In DB URL jdbc:mysql://10.27.40.35:3306,10.27.40.36:3306/fwcms_cdc_prod?autoReconnect=true, if the 10.27.40.35 server is down, then it gives below exception. But if i reverse the URL configuration to jdbc:mysql://10.27.40.36:3306,10.27.40.35:3306/fwcms_cdc_prod?autoReconnect=true, it works fine. Can you please help me to identify whats causing this issue?
At the starting i was thinking this is an driver issue. But with same driver, when i ran the standalone application, it worked without any issues.

12:06:08,782 ERROR [stderr] (MSC service thread 1-1) com.mysql.jdbc.jdbc2.optional.MysqlXAException: **Connection is read-only. Queries leading to data modificati
on are not allowed.**
12:06:08,784 ERROR [stderr] (MSC service thread 1-1) at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.mapXAExceptionFromSQLException(MysqlXAConnection.java
:607)
12:06:08,788 ERROR [stderr] (MSC service thread 1-1) at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:586)
12:06:08,790 ERROR [stderr] (MSC service thread 1-1) at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.start(MysqlXAConnection.java:526)
12:06:08,793 ERROR [stderr] (MSC service thread 1-1) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnection.start(XAManagedConnection.java:259)
12:06:08,796 ERROR [stderr] (MSC service thread 1-1) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.j
ava:636)
12:06:08,799 ERROR [stderr] (MSC service thread 1-1) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.j
ava:397)




Note: We are using the mysql-connector-java-5.1.12-bin.jar mysql driver as the the latest version 21 OR 24 OR 27 are giving below error:

java.lang.ClassCastException: $Proxy0 cannot be cast to com.mysql.jdbc.ConnectionImpl
Completed
at com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.wrapConnection(MysqlXADataSource.java:76)
at com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.getXAConnection(MysqlXADataSource.java:52)
Really appreciate your answers to fix this issue.

Regards,

Manjunath

Options: ReplyQuote




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.