0
votes

Using: Pivotal Cloudfoundry v2.x, Spring Cloud Data Flow Server v1.6.2.RELEASE, SQL Server 2016.

The server datasource configuration does not appear to successfully create a datasource if it is not a service bound to the application within PCF.

The SQL Server database is not a service provisioned within our PCF marketplace. I've rebuilt the server application and added the SQL Server jdbc driver jar to the classpath. I also included the datasource configuration:

---
applications: 
- path: spring-cloud-dataflow-server-cloudfoundry-1.6.2.RELEASE.jar
  name: dataflow-server
  host: dataflow-server
  memory: 4096M
  disk_quota: 2048M
  no-route: false
  no-hostname: false
  health-check-type: 'port' 
  buildpack: java_buildpack_offline
  env: 
    JAVA_OPTS: -Dhttp.keepAlive=false
    JBP_CONFIG_CONTAINER_CERTIFICATE_TRUST_STORE: '{enabled: true}' 
    SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_SPACE: channing
    SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_APP_NAME_PREFIX: channing
    SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_URL: https://api.pcf.com
    SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_DOMAIN: pcf.com
    SPRING_APPLICATION_NAME: dataflow-server
    SPRING_DATASOURCE_URL: jdbc:sqlserver://nonpcf.sqlserver.com\\DBINSTANCE:1713;databaseName=SCDF_DEV 
    SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.microsoft.sqlserver.jdbc.SQLServerDriver
    SPRING_DATASOURCE_USERNAME: username
    SPRING_DATASOURCE_PASSWORD: password
  services: 
    - config-server
    - rabbit
  security: 
    basic: 
      enabled: true
      realm: Spring Cloud Data Flow
  spring: 
    cloud: 
      dataflow: 
        features: 
          analytics-enabled: false

The error occurs during application startup, stating an unresolved dependency where there is no unique instance of javax.sql.DataSource available for injection.

Here is some stacktrace:

2018-10-23T09:39:14.365-06:00 [APP/PROC/WEB/0] [OUT] Caused by: org.springframework.cloud.CloudException: No unique service matching interface javax.sql.DataSource found. Expected 1, found 0
2018-10-23T09:39:14.365-06:00 [APP/PROC/WEB/0] [OUT] at org.springframework.cloud.Cloud.getSingletonServiceConnector(Cloud.java:197) ~[spring-cloud-connectors-core-2.0.2.RELEASE.jar!/:na]
2018-10-23T09:39:14.365-06:00 [APP/PROC/WEB/0] [OUT] at org.springframework.cloud.config.java.CloudServiceConnectionFactory.dataSource(CloudServiceConnectionFactory.java:56) ~[spring-cloud-spring-service-connector-2.0.2.RELEASE.jar!/:na]
2018-10-23T09:39:14.365-06:00 [APP/PROC/WEB/0] [OUT] at org.springframework.cloud.dataflow.server.cloudfoundry.config.DataSourceCloudConfig.scdfCloudDataSource(DataSourceCloudConfig.java:47) ~[spring-cloud-dataflow-server-cloudfoundry-autoconfig-1.6.2.RELEASE.jar!/:1.6.2.RELEASE]

Is this on purpose? How can we bind the PCF SCDF server with a datasource that is not resident within the foundation?

1

1 Answers

1
votes

Spring Cloud Data Flow's CF-server builds upon an opinion of relying on Spring Cloud Connector for datasource and connection-pool customization.

Since we do this intentionally to take advantage of the automation provided by the library, we don't have a direct ability to turn it off in SCDF itself.

However, there's an option to turn-off Spring Cloud Connector from interfering entirely, and that option is available as a Spring Boot property (i.e., spring.cloud=false), which also applies to SCDF, too.

With this property set at the CF-server, you'd be able to create a connection pool using the SPRING_DATASOURCE_* properties like how it is defined in the manifest.yml above.

UPDATE

Background: The declarative datasource overrides and Spring Cloud Connector (in the classpath) are mutually exclusive and they cannot work together in any capacity.

Hence, it is advised to stick to a single model when customizing the CF-server. The easiest solution in this case, of course, is to disable connector altogether.