JBoss 7 HSQLDB XA Datasource - java

I want to use a HSQLDB datasource with JBoss 7.
But I also want to use the datasource in XA mode.
As far as I know, HSQLDB supports XA-transactions since 2.2.0 and I am using the latest version of HSQLDB. I also found the corresponding class file in the HSQLDB jar: org.hsqldb.jdbc.pool.JDBCXAConnection.
But on startup I get the following exception from JBoss:
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:461)
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:398)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:781)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:344)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:397)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:365)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:329)
at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:464)
at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:139)
at org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.initDatabaseType(ProcessEngineConfigurationImpl.java:636) [camunda-engine-7.0.0-Final.jar:]
at org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.initDataSource(ProcessEngineConfigurationImpl.java:598) [camunda-engine-7.0.0-Final.jar:]
at org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:385) [camunda-engine-7.0.0-Final.jar:]
at org.camunda.bpm.engine.impl.cfg.JtaProcessEngineConfiguration.init(JtaProcessEngineConfiguration.java:54) [camunda-engine-7.0.0-Final.jar:]
at org.camunda.bpm.container.impl.jboss.config.ManagedJtaProcessEngineConfiguration.init(ManagedJtaProcessEngineConfiguration.java:34)
at org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:357) [camunda-engine-7.0.0-Final.jar:]
at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startProcessEngine(MscManagedProcessEngineController.java:178)
at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$2.run(MscManagedProcessEngineController.java:132)
at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$2.run(MscManagedProcessEngineController.java:130)
at org.camunda.bpm.container.impl.jboss.util.Tccl.runWithTccl(Tccl.java:53)
at org.camunda.bpm.container.impl.jboss.util.Tccl.runUnderClassloader(Tccl.java:45)
at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startInternal(MscManagedProcessEngineController.java:130)
at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$1.run(MscManagedProcessEngineController.java:91)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_07]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_07]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
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:603)
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:444)
... 29 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:578)
... 30 more
Here is my datasource configuration:
<xa-datasource jndi-name="java:jboss/datasources/LiferayDS" pool-name="LiferayDS" enabled="true" use-ccm="false">
<xa-datasource-property name="URL">
jdbc:hsqldb:file:../../hsql-data/LiferayDS
</xa-datasource-property>
<driver>hsqldb</driver>
<xa-pool>
<max-pool-size>10</max-pool-size>
<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>sa</user-name>
<password></password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
It looks like the XA class from HSQLDB doesn't provide the common XA configuration interface.
How must I configure the datasource to be able to use HSQLDB in transaction mode?

Ok, here is the correct configuration for a HSQLDB xa-datasource
<xa-datasource jndi-name="java:jboss/datasources/LiferayDS" pool-name="LiferayDS" enabled="true" use-ccm="false">
<xa-datasource-property name="Url">
jdbc:hsqldb:file:../../hsql-data/LiferayDS
</xa-datasource-property>
<driver>hsqldb</driver>
<xa-pool>
<max-pool-size>10</max-pool-size>
<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>sa</user-name>
<password></password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>

Related

fail to migration from jboss as 6 to jboss eap 7.1 with -ds.xml configuration

this is the first time for question.
Please help me to solve this problem.
I've been completed to migration from AS6 to EAP7.1. but, It still has problem with -ds.xml
10:26:01,286 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "mySource.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"mySource.war\".FIRST_MODULE_USE" => "WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"mySource.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJCA0064: Exception deploying datasource java:jboss/datasources/jt400
Caused by: java.lang.IllegalArgumentException: Empty name segment is not allowed for jdbc-driver"}}
upper is the problem log when i tried to debug my source on the JBoss EAP 7.x.
and below is one of my jt400.xml file contents.
<datasource connectable="false" enabled="true" jndi-name="java:jboss/datasources/jt400" jta="true" pool-name="jt400" spy="false" use-ccm="true" use-java-context="true">
<connection-url>jdbc:as400://127.0.0.1</connection-url>
<driver-class>com.ibm.as400.access.AS400JDBCDriver</driver-class>
<datasource-class/>
<driver/>
<transaction-isolation>TRANSACTION_NONE</transaction-isolation>
<pool>
<min-pool-size>0</min-pool-size>
<initial-pool-size>0</initial-pool-size>
<max-pool-size>30</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
<validation>
<check-valid-connection-sql>SELECT * FROM SYSIBM.SYSDUMMY1</check-valid-connection-sql>
<use-fast-fail>false</use-fast-fail>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<xa-resource-timeout>0</xa-resource-timeout>
</timeout>
<statement>
<track-statements>false</track-statements>
</statement>
</datasource>
finally, I was copy the driver file (jt400.jar) into the standalone/lib path.
I don't have any idea to solve this problem...
Please anybody help me... It seriously headache for me haha...
Thankyou!
I think that your problem is this line driver. It can't be empty, you need to define the driver. By example:
<driver>mysql</driver>
and after the just define the driver itself, in this example:
<drivers>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.cj.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
If you add that area you will resolve the error message.

How to fix the "tables are already present using metadata" camunda process engine exception?

I am using wildfly 14.0.1 Application server and Camunda V 7.11.0. I have configured mysql db instead of the default camunda h2 db and added the below data-sources to the standalone.xml file. But I get the below exception at deployment. How do I get this exception fixed?
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/camunda11?jdbcCompliantTruncation=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/camunda11?sessionVariables=sql_mode='NO_ENGINE_SUBSTITUTION'&jdbcCompliantTruncation=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
11:47:10,206 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 72) MSC000001: Failed to start service org.camunda.bpm.platform.process-engine.default: org.jboss.msc.service.StartException in service org.camunda.bpm.platform.process-engine.default: org.camunda.bpm.engine.ProcessEngineException: ENGINE-03018 Could not check if tables are already present using metadata.
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$1.run(MscManagedProcessEngineController.java:98)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1349)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads#2.3.2.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-03018 Could not check if tables are already present using metadata.
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.checkDatabaseTableException(EnginePersistenceLogger.java:241)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.sql.DbSqlSession.isTablePresent(DbSqlSession.java:494)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.sql.DbSqlSession.isEngineTablePresent(DbSqlSession.java:434)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.db.AbstractPersistenceSession.dbSchemaUpdate(AbstractPersistenceSession.java:218)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:56)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:34)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:107)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.ProcessEngineImpl.executeSchemaOperations(ProcessEngineImpl.java:120)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:93)
at org.camunda.bpm.camunda-engine#7.11.0//org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:798)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startProcessEngine(MscManagedProcessEngineController.java:178)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$2.run(MscManagedProcessEngineController.java:132)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$2.run(MscManagedProcessEngineController.java:130)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.util.Tccl.runWithTccl(Tccl.java:54)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.util.Tccl.runUnderClassloader(Tccl.java:46)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startInternal(MscManagedProcessEngineController.java:130)
at org.camunda.bpm.wildfly.camunda-wildfly-subsystem#7.11.0//org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$1.run(MscManagedProcessEngineController.java:91)
... 8 more
Caused by: org.apache.ibatis.exceptions.PersistenceException:
I used the mysql-connector-java-5.1.44.jar instead of the 5.1.6 version to fix the exception.

Reconnect to oracle db after restart from Wildfly datasource

I have a product that uses Wildfly datasource to connect to Oracle DB.
Our Database servers have a scheduled weekly cold backup and for this reason the DB will shutdown every week for approx 10 mins. Then i am forced to restart the application after the DB is started.
How do i configure my Wildfly datasource to check and reconnect after the db is started ?
Wildfly version: wildfly-8.2.0.Final
Data source configuration -
<datasource jndi-name="java:/REQUESTDS" pool-name="REQUESTDS" enabled="true">
<connection-url>jdbc:oracle:thin:#localhost:1521:MYDB</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<connection-property name="selectMethod">
direct
</connection-property>
<connection-property name="sendStringParametersAsUnicode">
true
</connection-property>
<driver>oracle-thin</driver>
<new-connection-sql>SELECT 1 FROM DUAL</new-connection-sql>
<pool>
<min-pool-size>20</min-pool-size>
<max-pool-size>80</max-pool-size>
<prefill>true</prefill>
<use-strict-min>true</use-strict-min>
</pool>
<security>
<security-domain>CompanySecureDataSource</security-domain>
</security>
<validation>
<validate-on-match>true</validate-on-match>
</validation>
<timeout>
<blocking-timeout-millis>90000</blocking-timeout-millis>
<allocation-retry>40</allocation-retry>
<allocation-retry-wait-millis>30000</allocation-retry-wait-millis>
</timeout>
</datasource>
I have checked my threads here and tried most of them. But in vain.
What is the correct setting that will check and reconnect to oracle db
Using background-validation and the pool will try to create new connections if any one of them dies.
<validation>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
<background-validation-millis>20000</background-validation-millis>
</validation>

Deploying WAR-Application in JBoss Wildfly with unavailable DataSource?

I have a web application which uses JPA persistence under wildfly 8.2.
The persistence.xml is connected to <jta-data-source>java:/jdbc/myDS</jta-data-source> which generally works fine.
BUT if I start the JBoss-Server before the Database-Server is ready, the web application doesn't get deployed with the following error:
BAS011411: Unexpected problem gathering statistics: java.lang.IllegalStateException: JBAS011477: Persistence unit 'my.war#myPU' is not available
My wish is that the application DOES get deployed (and throws an exception when is accessed) even when the DB-server is not available.
Is that possible?
My datasource-definition:
<datasource jndi-name="java:/jdbc/myDS" pool-name="myDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>15</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>myuser</user-name>
<password>mypwd</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<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>
</datasource>
Steps to reproduce:
Deploy an app with a "valid" datasource definition but keep the database server offline

How to know the number of connection pools created in JBOSS application server

I am using jboss 7.0 for web application. In standalone.xml file, I have defined datasource as ,
<datasource jndi-name="java:jboss/datasources/finacpacds" pool-name="ltmscompanyadmindspool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/finacpac?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
</connection-url>
<driver>
mysqldriver
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
<pool>
<min-pool-size>
10
</min-pool-size>
<max-pool-size>
50
</max-pool-size>
<prefill>
true
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
root
</user-name>
<password>
</password>
</security>
<validation>
<validate-on-match>
false
</validate-on-match>
<background-validation>
false
</background-validation>
<useFastFail>
false
</useFastFail>
</validation>
<statement>
<prepared-statement-cache-size>
100
</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
Now my question is can i see the number of connection pools created when jboss is running by system.out.print statement. Is there any way to do this.
You cannot print out that info to System.out. You can read datasource statistics via CLI:
/subsystem=datasources/data-source=ltmscompanyadmindspool/statistics=pool:read-resource(include-runtime=true)
/subsystem=datasources/data-source=ltmscompanyadmindspool/statistics=jdbc:read-resource(include-runtime=true)
You can read more about statistics here.
On a side note, your datasource configuration is a bit concerning. Why would you have the validations disabled? If you do this then when there is an outage or a restart of the database server JBoss won't be able to validate/refresh the connections without a restart of the JBoss server.

Categories