You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maxim Sukhotin <ma...@sukhotin.info> on 2017/11/23 11:55:58 UTC

Unable to use Tomcat JDBC CP with XA connections

Hello,
I have Tomcat 8.5.23 with following context.xml:

<Resource name="jdbc/pgxads"
auth="Container"
type="org.postgresql.xa.PGXADataSource"
factory="org.apache.tomcat.jdbc.naming.GenericNamingResourcesFactory"
serverName="db"
databaseName="postgres"
user="postgres"
password="postgres"
/>

<Resource name="sharedDataSource"
auth="Container"
type="javax.sql.XADataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
dataSourceJNDI="jdbc/pgxads"
timeBetweenEvictionRunsMillis="34000"
minEvictableIdleTimeMillis="55000"
testOnBorrow="true"
testOnCreate="true"
validationInterval="34000"
validationQuery="select 1"
/>

It declares XADataSource using Tomcat JDBC CP. When I retrieve a
connection I get the following exception:
org.postgresql.util.PSQLException: Connection has been closed.

If I declare connection without Tomcat CP it works ok:

<Resource name="sharedDataSource"
auth="Container"
type="org.postgresql.xa.PGXADataSource"
factory="org.postgresql.xa.PGXADataSourceFactory"
serverName="db"
databaseName="postgres"
user="postgres"
password="postgres"
/>

Do I have any errors in my configuration?
I prepared a simple demo app on github for problem demonstration:
https://github.com/Speedbird/ds-test
To reproduce problem run: "mvn clean package && docker-compose up"

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org