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

Comment From: wilkinsona

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.

Comment From: rob-valor

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)

Comment From: wilkinsona

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

Comment From: wilkinsona

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.