JBPM7.1+Tomcat8+Postgresql ClassCastException javax.sql.XADataSource

239 views
Skip to first unread message

Ripin Yan

unread,
Sep 29, 2017, 5:14:11 AM9/29/17
to jBPM Usage
Hi, Maciej,
deploy the kie-server service in tomcat8,and the database is postgresql.
     When I start the service, it throws an exception:
----
29-Sep-2017 16:13:39.403 ERROR [Periodic Recovery] com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createDataSource java.lang.ClassCastException: org.apache.tomcat.jdbc.pool.DataSource cannot be cast to javax.sql.XADataSource
29-Sep-2017 16:13:39.404 WARN [Periodic Recovery] com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecovery ARJUNA016009: Caught:
java.sql.SQLException: java.lang.ClassCastException: org.apache.tomcat.jdbc.pool.DataSource cannot be cast to javax.sql.XADataSource
at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createDataSource(IndirectRecoverableConnection.java:370)
at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.<init>(IndirectRecoverableConnection.java:109)
at com.arjuna.ats.internal.jdbc.ConnectionImple.<init>(ConnectionImple.java:116)
at com.arjuna.ats.internal.jdbc.recovery.JDBC2RecoveryConnection.<init>(JDBC2RecoveryConnection.java:55)
at com.arjuna.ats.internal.jdbc.recovery.BasicXARecovery.getConnection(BasicXARecovery.java:201)
at com.arjuna.ats.internal.jdbc.recovery.BasicXARecovery.getXAResource(BasicXARecovery.java:160)
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecovery(XARecoveryModule.java:547)
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:186)
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:140)
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:765)
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:377)
Caused by: java.lang.ClassCastException: org.apache.tomcat.jdbc.pool.DataSource cannot be cast to javax.sql.XADataSource
at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createDataSource(IndirectRecoverableConnection.java:355)
... 10 more
---
 

  1. context.xml
 <Resource name="jbpmDS"
            auth="Container"
            type="javax.sql.DataSource"
            username="jbpm"
            password="jbpm"
            url="jdbc:postgresql://localhost:5432/jbpm"
            description="PG Data Source"
            driverClassName="org.postgresql.Driver"
            maxWait="-1"
            maxActive="20"
            maxIdle="10"
            />

2. setenv.sh
CATALINA_OPTS="
-Xmx512M 
-Djbpm.tsr.jndi.lookup=java:comp/env/TransactionSynchronizationRegistry 
-Dorg.kie.server.persistence.ds=java:comp/env/jdbc/jbpm
-Djbpm.tm.jndi.lookup=java:comp/env/TransactionManager
-Dorg.kie.server.persistence.dialect=org.hibernate.dialect.PostgreSQLDialect
-Dorg.kie.server.bypass.auth.user=true
-Dorg.jbpm.ht.callback=db
-Dorg.jbpm.ht.userinfo=db
-Dhibernate.connection.release_mode=after_transaction 
-Dorg.kie.server.id=default-kieserver
-Dorg.kie.server.user=kieserver
-Dorg.kie.server.pwd=kieserver1!
-Dcom.arjuna.ats.jta.recovery.XAResourceRecovery1=com.arjuna.ats.internal.jdbc.recovery.BasicXARecovery\;abs://$CATALINA_HOME/conf/xa-recovery-properties.xml\ \;1
"
 


Can you tell me how to solve this problem?


best regards,
ripin


Maciej Swiderski

unread,
Sep 29, 2017, 7:40:16 AM9/29/17
to Ripin Yan, jBPM Usage
make sure it actually shows all the steps and their content so look at the raw format of this readme:

Maciej
--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/838b3b15-3cf1-4cd3-b133-19cc79f94f5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ripin Yan

unread,
Sep 30, 2017, 2:30:42 AM9/30/17
to jBPM Usage
modified the type/factory of resource
<Resource name="sharedDataSource"
            type="org.postgresql.xa.PGXADataSource"
            username="jbpm"
            password="jbpm"
            url="jdbc:postgresql://localhost:5432/jbpm"
            description="PG Data Source"
            driverClassName="org.postgresql.Driver"
            maxWait="-1"
            maxActive="20"
            maxIdle="10"
            databaseName="jbpm"
            portNumber="5432"
            serverName="localhost"
            factory="org.postgresql.xa.PGXADataSourceFactory"
            />

it works.
But when I turn on callback with db,i have a new problem in the DBUserGroupCallbackImpl.java,using DataSource instead of XADataSource,very curious how jboss can be successfully used to PGXADataSource to ds.
String jndiName = this.config.getProperty(DS_JNDI_NAME, "java:/DefaultDS");
try {
InitialContext ctx = new InitialContext();

ds = (DataSource) ctx.lookup(jndiName);

} catch (Exception e) {
throw new IllegalStateException("Can get data source for DB usergroup callback, JNDI name: " + jndiName, e);
}




  1. 30-Sep-2017 11:58:15.637 严重 [localhost-startStop-1] org.kie.server.services.impl.KieServerImpl.<init> Error when initializing server extension of type jBPM KIE Server extension
  2. java.lang.IllegalStateException: Can get data source for DB usergroup callback, JNDI name: java:comp/env/sharedDataSource
  3. at org.jbpm.services.task.identity.DBUserGroupCallbackImpl.init(DBUserGroupCallbackImpl.java:158)
  4. at org.jbpm.services.task.identity.DBUserGroupCallbackImpl.<init>(DBUserGroupCallbackImpl.java:65)
  5. at org.jbpm.runtime.manager.impl.identity.UserDataServiceProvider.getUserGroupCallback(UserDataServiceProvider.java:77)
  6. at org.kie.server.services.jbpm.JbpmKieServerExtension.init(JbpmKieServerExtension.java:204)
  7. at org.kie.server.services.impl.KieServerImpl.<init>(KieServerImpl.java:119)
  8. at org.kie.server.services.impl.KieServerImpl.<init>(KieServerImpl.java:96)
  9. at org.kie.server.services.impl.KieServerLocator.<clinit>(KieServerLocator.java:20)
  10. at org.kie.server.services.Bootstrap.contextInitialized(Bootstrap.java:49)
  11. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
  12. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
  13. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  14. at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
  15. at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
  16. at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
  17. at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
  18. at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
  19. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  20. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  21. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  22. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  23. at java.lang.Thread.run(Thread.java:745)
  24. Caused by: java.lang.ClassCastException: org.postgresql.xa.PGXADataSource cannot be cast to javax.sql.DataSource
  25. at org.jbpm.services.task.identity.DBUserGroupCallbackImpl.init(DBUserGroupCallbackImpl.java:155)
  26. ... 20 more





在 2017年9月29日星期五 UTC+8下午7:40:16,Maciej Swiderski写道:

Maciej Swiderski

unread,
Oct 2, 2017, 1:12:37 AM10/2/17
to Ripin Yan, jBPM Usage
maybe try to set the type to interface of the data source instead of Postgres implementation:
type="javax.sql.DataSource"
Maciej

Ripin Yan

unread,
Oct 11, 2017, 10:22:17 AM10/11/17
to jBPM Usage
when i modify the args of jbpm.user.info.properties

db.ds.jndi.name=java:comp/env/jdbc/jbpm


it works.

在 2017年10月2日星期一 UTC+8下午1:12:37,Maciej Swiderski写道:
Reply all
Reply to author
Forward
0 new messages