I am trying to push a spring application to PCF. In doing so, I get the following error: The user provided services exist.
Error creating bean with name 'dataSourceNWTC' defined in class path resource [com/*//****/*//config/CloudConfig.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.sql.DataSource com.*****.....config.CloudConfig.nwPrepDataSource()] threw exception; nested exception is org.springframework.cloud.CloudException: No suitable ServiceConnectorCreator found: service id=dataSource-NWTC, service info type=org.springframework.cloud.service.BaseServiceInfo, connector type=interface javax.sql.DataSource
I have tried this with several versions.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
<version>2.0.6.RELEASE</version>
<repositories>
<repository>
<id>repository.springsource.milestone</id>
<name>SpringSource Milestone Repository</name>
<url>http://repo.springsource.org/milestone</url>
</repository>
@Configuration
@ServiceScan
@Profile("cloud")
public class CloudConfig extends AbstractCloudConfig {
@Bean(name = "dataSourceAIMS")
public DataSource aimsDataSource() {
return connectionFactory().dataSource("dataSource-AIMS");
}
@Bean(name = "dataSourceNWTC")
public DataSource nwPrepDataSource() {
return connectionFactory().dataSource("dataSource-NWTC");
}
}
applications:
- name: some-name
path: target/some-name-1.0-SNAPSHOT.war
random-route: true
buildpacks:
- java_buildpack_offline
services:
- dataSource-AIMS
- dataSource-NWTC
env:
SPRING_PROFILES_ACTIVE: cloud
No suitable ServiceConnectorCreator found
You'll see this when Spring Cloud Connectors doesn't know how to make a service object from the service info it's got in VCAP_SERVICES
. Look at VCAP_SERVICES
and see if the type of service is supported by SCC. Also, look and confirm that the service info is structured in a way that the supported DB types would be able to understand.
Aside from that, I would strongly suggest you take a look at java-cfenv instead of Spring Cloud Connectors. I believe that is intended to be the successor to Spring Cloud Connectors.
Hope that helps!