I am working on a grails 2.5.3 app that will be deployed to cloudfoundry. The app is bound with few services and in order to get the values for those services I use two connectors:
//s3 service connector
compile ("org.cloudfoundry.community:spring-cloud-s3-service-connector:1.0.0") {
excludes "aws-java-sdk", 'slf4j-api', 'slf4j-log4j12', 'slf4j'
}
//sso service connector
compile (group: 'io.pivotal.spring.cloud', name: 'spring-cloud-sso-connector', version: '1.1.0.RELEASE') {
excludes 'slf4j-api', 'slf4j-log4j12', 'slf4j'
}
When I use both of these I get an error in my application:
org.springframework.cloud.CloudConnector: Provider org.springframework.cloud.cloudfoundry.CloudFoundryConnector could not be instantiated
Caused by: java.lang.NoSuchMethodError: org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator.(Lorg/springframework/cloud/cloudfoundry/Tags;[Ljava/lang/String;)V at io.pivotal.spring.cloud.SsoServiceInfoCreator.(SsoServiceInfoCreator.java:11)
I believe the error is happening because each of these services have a services
folder under META-INF
and apparently only one is picked when both of these are used simultaneously.
The META-INF/services
folder for both is here:
SSO Connector: https://github.com/pivotal-cf/spring-cloud-sso-connector/tree/master/src/main/resources/META-INF/services
S3 Connector: https://github.com/cloudfoundry-community/spring-cloud-s3-service-connector/tree/master/src/main/resources/META-INF/services
I'm not sure how to resolve this error. I've tried various combinations but none seem to work.
Update
I've added a second question that is related to this https://stackoverflow.com/questions/42976791/common-dependency-for-two-packages-gets-dropped-when-both-pages-are-used
Having multiple Connector extension libs on the classpath is common, each with their own
META-INF/services
. This shouldn't be a problem.In your other question, you have:
and
This shows that
spring-cloud-s3-service-connector:1.0.0
transitively depends onspring-cloud-core:1.0.0.RELEASE
, whilespring-cloud-sso-connector:1.1.0.RELEASE
depends onspring-cloud-core:1.1.1.RELEASE
. The build system will only pull in one version ofspring-cloud-core
, and it appears thatspring-cloud-core:1.0.0.RELEASE
is the one that is actually getting pulled in andspring-cloud-sso-connector
isn't compatible with that older version.There is a
spring-cloud-s3-service-connector:1.1.0
available in Maven Central, try upgrading to that version.