All,
I have a spring boot app that gives me an error, when I try to push to IBM Bluemix/CloudFoundry.
This is a spring boot app, using spring cloud and trying to connect to a relational db service (sqldb which is a cloud version of DB2) service.
I could connect without spring cloud, where I explicitly specified the db credentials from vcap_services in my property file. However I am trying to avoid that using spring cloud abstraction, but gets the error mentioned below.
My expectation is the spring boot/cloud should identify the test-sqldb service I bound to the app and create a data source on the fly. Instead I get the error given below when I do cf push.
Is it fair to assume that spring boot/cloud pair will orchestrate the data source for me as I have the db2 driver jar and attached service in environment.? If not, can some one point to me what am I missing?
Pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependenc
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc </artifactId>
<version>10.5</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
</dependency>
</dependencies>
I have following config in spring context file as given below as mentioned in this link. Using the cloud profile to separate from my local datasource config.
spring config - this is imported to my spring context and is in effect when I run with cloud profile
<beans profile="cloud">
<cloud:data-source id="dataSourcePref" service-name="test-sqldb">
<!-- <cloud:pool-data-sources>
<value>TomcatJdbc</value>
<value>TomcatDbcp</value>
<value>BasicDbcp</value>
</cloud:pool-data-sources>-->
</cloud:data-source>
</beans>
Spring Boot Application Class
@SpringBootApplication
@ImportResource("classpath:/META-INF/spring/my-jpa-beans.xml")
public class JpaTestApplication {
public static void main(String[] args) {
SpringApplication.run(JpaTestApplication.class, args);
}
}
Error
2015-10-28T09:47:11.11-0700 [App/0] OUT 2015-10-28 16:47:11.115 ERROR 29 --- [ main] o.s.boot.SpringApplication : Application startup failed
2015-10-28T09:47:11.11-0700 [App/0] OUT org.springframework.beans.factory.BeanCreationException: Error registering service factory; nested exception is org.springframework.cloud.CloudException: No suitable ServiceConnectorCreator found: service id=test-sqldb, service info type=org.springframework.cloud.service.BaseServiceInfo, connector type=interface javax.sql.DataSource
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.config.xml.CloudServiceIntroducer.postProcessBeanFactory(AbstractCloudServiceFactoryParser.java:90)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:177)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:607)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
2015-10-28T09:47:11.11-0700 [App/0] OUT at com.example.JpaTestApplication.main(JpaTestApplication.java:14)
2015-10-28T09:47:11.11-0700 [App/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2015-10-28T09:47:11.11-0700 [App/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2015-10-28T09:47:11.11-0700 [App/0] OUT at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2015-10-28T09:47:11.11-0700 [App/0] OUT at java.lang.reflect.Method.invoke(Method.java:497)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
2015-10-28T09:47:11.11-0700 [App/0] OUT at java.lang.Thread.run(Thread.java:745)
2015-10-28T09:47:11.11-0700 [App/0] OUT Caused by: org.springframework.cloud.CloudException: No suitable ServiceConnectorCreator found: service id=test-sqldb, service info type=org.springframework.cloud.service.BaseServiceInfo, connector type=interface javax.sql.DataSource
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.ServiceConnectorCreatorRegistry.getServiceCreator(Cloud.java:356)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.Cloud.getServiceConnector(Cloud.java:255)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.Cloud.getServiceConnector(Cloud.java:142)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.service.AbstractCloudServiceConnectorFactory.createService(AbstractCloudServiceConnectorFactory.java:103)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.service.AbstractCloudServiceConnectorFactory.createInstance(AbstractCloudServiceConnectorFactory.java:98)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.service.AbstractCloudServiceConnectorFactory.afterPropertiesSet(AbstractCloudServiceConnectorFactory.java:93)
2015-10-28T09:47:11.11-0700 [App/0] OUT at org.springframework.cloud.config.xml.CloudServiceIntroducer.postProcessBeanFactory(AbstractCloudServiceFactoryParser.java:82)
2015-10-28T09:47:11.11-0700 [App/0] OUT ... 16 common frames omitted
2015-10-28T09:47:11.26-0700 [DEA/17] ERR Instance (index 0) failed to start accepting connections
Seems I understood what is happening.
An answer in this thread mentions about Service connectors that gave me a hint.
SqlDb need DB2DataSourceCreator which was not available in spring-cloud-connectors version 1.1.1-release, which I was using. It supports others like MySQL, Postgres, Redis, MongoDB, RabbitMQ, etc..
Upgraded to 1.2.0-release and I am able to pass this error point. Thanks for two of you who tried to help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.