xa-datasource configuration problem with MariaDB
cedric-henry Apr 22, 2019 8:06 AMI am doing maintenance in an application hosted on JBoss EAP 6.4, on which we are moving from MySQL to MariaDB.
The last step is about using the MariaDB client (org.mariadb.jdbc:mariadb-java-client:2.4.0), for which I have set my data source as follow:
<xa-datasource jndi-name="java:jboss/jdbc/MyDatasource" pool-name="MyDS_pool" enabled="true" use-java-context="true"> <xa-datasource-property name="URL"> jdbc:mariadb://${database.ip.address}:${database.port}/${database.name}?${database.properties} </xa-datasource-property> <driver>mariaDB</driver> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <xa-pool> <min-pool-size>10</min-pool-size> <max-pool-size>30</max-pool-size> </xa-pool> <security> <user-name>${database.user}</user-name> <password>${database.password}</password> </security> <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/> <check-valid-connection-sql>select 1</check-valid-connection-sql> <validate-on-match>false</validate-on-match> <background-validation>true</background-validation> <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/> </validation> <timeout> <idle-timeout-minutes>10</idle-timeout-minutes> </timeout> <statement> <prepared-statement-cache-size>32</prepared-statement-cache-size> </statement> </xa-datasource>
Unfortunately, the connection creation fails:
14:08:46,599 INFO [org.hibernate.cfg.Configuration] (ServerService Thread Pool -- 56) HHH000041: Configured SessionFactory: null 14:08:46,696 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (ServerService Thread Pool -- 56) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: Could not create connection at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:525) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:434) at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:834) at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:379) at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:453) at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:425) at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:354) at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368) at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:510) at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:143) at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1827) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1785) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870) [hibernate-core-4.2.18.Final-redhat-2.jar:4.2.18.Final-redhat-2] at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) [spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434) [spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1] at org.apache.catalina.core.StandardContext.start(StandardContext.java:3780) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1] at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21] at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21] at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_121] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_121] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_121] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_121] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121] at org.jboss.threads.JBossThread.run(JBossThread.java:122) Caused by: javax.resource.ResourceException: Could not find accessor on XADataSource: at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:680) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:508) ... 46 more Caused by: java.lang.NoSuchMethodException: Method setURL not found at org.jboss.jca.adapters.jdbc.util.Injection.inject(Injection.java:141) at org.jboss.jca.adapters.jdbc.util.Injection.inject(Injection.java:70) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:655) ... 47 more
Updated
To resolve the java.lang.NoSuchMethodException issue I had to edit the property name from:
<xa-datasource-property name="URL">
To
<xa-datasource-property name="Url">