Skip to content

XADataSourceAutoConfiguration is difficult to use with DB2XADataSource as it does not have a URL property #20229

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

Closed
rob-valor opened this issue Feb 19, 2020 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@rob-valor
Copy link
Contributor

Spring Boot version: all

When using an XADataSource which has no property url to be set, the XADataSourceAutoConfiguration will always do source.put("url", this.properties.determineUrl()); which fails when no url is provided.

Since there is no url property to be set on the XADataSource we use and all required configuration properties are already located in the DataSourceProperties.Xa#getProperties I don't see why this should fail. For a simple DataSource build by dataSourceProperties().initializeDataSourceBuilder().build() it is valid to fail because it depends on the url.

I would prefer to have a method which is able to return null like DataSourceProperties#determineUsername and DataSourceProperties#determinePassword to be used in the XADataSourceAutoConfiguration. Now with property spring.datasource.url=just to be able to start we are able to start, although that property is not used for the XADataSource

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 19, 2020
@wilkinsona
Copy link
Member

Thanks for the report. To make sure that we fully understand the problem, I'd like to know a bit more about the XADataSource that you're using and how it works without a URL. A minimal sample that reproduces the problem would be the ideal way to share that information with us.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Mar 19, 2020
@rob-valor
Copy link
Contributor Author

rob-valor commented Mar 19, 2020

sping-boot-issue-20229.zip

This sample does not use an embedded db (not really suitable as DB2 replacement). It is a similar test setup as the one we use.

The 2 tests show the DB2XADataSource does not use anything of url. Only the DataSourceProperties.Xa configuration is used to instantiate a correct XADataSource instance.

Creating this example I found out that spring.datasource.url also needs the jdbc:db2:// when spring.datasource.username and/or spring.datasource.password are not set because there is a check for embedded database but again that is not our case because no embedded database to replace IBM DB2. We spin up a DB2 container for out tests (so spring.test.database.replace=none)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 19, 2020
@wilkinsona
Copy link
Member

Thanks for the sample. I can see now that com.ibm.db2.jcc.DB2XADataSource uses a number of separate properties to configure what would typically be configured via the URL:

spring:
  datasource:
    xa:
      data-source-class-name:
        com.ibm.db2.jcc.DB2XADataSource
      properties:
        allowNextOnExhaustedResultSet: 1
        databaseName: whereAreYou
        driverType: 4
        password: It is I, Leclerc
        portNumber: 5000
        serverName: localhost
        user: AlloAllo

@wilkinsona wilkinsona changed the title XADataSourceAutoConfiguration should not fail on missing spring.datasource.url XADataSourceAutoConfiguration is difficult to use with DB2XADataSource as it does not have a URL property Mar 20, 2020
@wilkinsona wilkinsona added type: bug A general bug and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Mar 20, 2020
@wilkinsona wilkinsona added this to the 2.2.x milestone Mar 20, 2020
@wilkinsona
Copy link
Member

I've marked this as a bug to be fixed in 2.2.x for now at least. We'll have to see what's possible within the constraints of a maintenance release. If necessary, we may need to defer this to 2.3 where would could afford to make more extensive changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants