Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: JDBC javax.sql.XADatasource type pool doesn't return XADatasource instance #6450

Open
sabrieker opened this issue Oct 13, 2023 · 1 comment
Assignees
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect

Comments

@sabrieker
Copy link

Brief Summary

We configure the jdbc connection pool to be an javax.sql.XADataSource but when we query the data source in code to determine if it is an javax.sql.XADataSource then we have the following code,

ds.unwrap(javax.sql.XADataSource)

and this throws an exception because the DataSource we receive does not implement javax.sql.XADataSource.

Configurations used to define the connection pool.

create-jdbc-connection-pool --datasourceclassname=com.ibm.db2.jcc.DB2XADataSource --restype=javax.sql.XADataSource --property user=\${ENV\=DB2USER}:password=\${ENV\=DB2PASS}:databaseName=\${ENV\=DB2NAME}:portNumber=\${ENV\=DB2PORT}:driverType=4:serverName=\${ENV\=DB2HOST}:sslConnection=true:dateFormat=3:timeFormat=3:minPoolSize=4:maxPoolSize=10:allowLocalTransactions=false:enableJdbc4ConnectionTest=true:isolationLevel=READ_COMMITTED xaDataSourcePool
create-jdbc-resource --connectionpoolid xaDataSourcePool jdbc/XA

We see javax.sql.XADatasource type at the admin console too.

When we check the datasource it is an instance of com.sun.gjc.spi.jdbc40.DataSource40 class.

Expected Outcome

We expect a datasource instance which implements javax.sql.XADataSource otherwise we can not decide if if is a XA or not.

Current Outcome

We got an instance of com.sun.gjc.spi.jdbc40.DataSource40 class and it is implementing javax.sql.Datasource not javax.sql.XADatasource.

Reproducer

Declare a datasource and retrieve it with following case, you can see the SQLException.

try {
InitialContext  namingContext=new InitialContext()
			        ds=(DataSource)(namingContext.lookup(datasource));
			    } catch (Exception e) {
                    
	            
				final java.sql.Connection con;
				boolean usingDataSource=false;
				boolean isXADataSource=false;
				
              	               con=ds.getConnection();
				try{
                                   ds.unwrap(javax.sql.XADataSource.class);
					        isXADataSource=true;
				}
				catch (SQLException sqle) {
						isXADataSource=false;
					}
				}

Operating System

macOS Monterey / Version 6.2023.6

JDK Version

openjdk/17.0.2

Payara Distribution

Payara Server Full Profile

@sabrieker sabrieker added Status: Open Issue has been triaged by the front-line engineers and is being worked on verification Type: Bug Label issue as a bug defect labels Oct 13, 2023
@artur-mal
Copy link

Greetings @sabrieker

I was able to reproduce the issue by casting directly to XADataSource:

XADataSource xaDS = (XADataSource) initialContext.lookup("JDBC_XA_Resource")

I have escalated this to the platform development team with internal JIRA FISH-7952.
I will let you know once we are able to proceed with the development of the fix.

Regards,
Artur

@artur-mal artur-mal added Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev and removed Status: Open Issue has been triaged by the front-line engineers and is being worked on verification labels Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Bug Label issue as a bug defect
Projects
None yet
Development

No branches or pull requests

2 participants