cloudfoundry / docs-buildpacks

http://docs.cloudfoundry.org/buildpacks/
Apache License 2.0
21 stars 118 forks source link

Migration to java-cfenv from spring-cloud-connectors-core UriBasedServiceInfo dependency #298

Closed Marveljyz closed 1 year ago

Marveljyz commented 1 year ago

Hello! Currently facing below issue while trying to migrate to java-cfenv from spring-cloud-connectors-core. Any advice on how to resolve this will greatly be appreciated.

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/cloud/service/UriBasedServiceInfo at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:90) at java.lang.Class.getGenericSuperclass(Class.java:777) at org.springframework.core.ResolvableType.getSuperType(ResolvableType.java:471) at org.springframework.core.ResolvableType.as(ResolvableType.java:456) at org.springframework.context.event.GenericApplicationListenerAdapter.resolveDeclaredEventType(GenericApplicationListenerAdapter.java:112) at org.springframework.context.event.GenericApplicationListenerAdapter.resolveDeclaredEventType(GenericApplicationListenerAdapter.java:98) at org.springframework.context.event.GenericApplicationListenerAdapter.(GenericApplicationListenerAdapter.java:58) at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:359) at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:231) at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:204) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:134) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:74) at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47) at org.springframework.boot.SpringApplication.run(SpringApplication.java:304) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236)

cf-gitbot commented 1 year ago

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

ryanmoran commented 1 year ago

@pivotal-david-osullivan any thoughts?

pivotal-david-osullivan commented 1 year ago

Can you please share your dependencies file?

Marveljyz commented 1 year ago

Thank you, for looking into this. Below is the dependency tree of the app:

+- io.springfox:springfox-swagger2:jar:3.0.0:compile [INFO] | +- io.springfox:springfox-spi:jar:3.0.0:compile [INFO] | | - io.springfox:springfox-core:jar:3.0.0:compile [INFO] | | - net.bytebuddy:byte-buddy:jar:1.10.22:compile [INFO] | +- io.springfox:springfox-schema:jar:3.0.0:compile [INFO] | +- io.springfox:springfox-swagger-common:jar:3.0.0:compile [INFO] | | - io.swagger.core.v3:swagger-annotations:jar:2.1.2:compile [INFO] | +- io.springfox:springfox-spring-web:jar:3.0.0:compile [INFO] | | - io.github.classgraph:classgraph:jar:4.8.83:compile [INFO] | +- io.springfox:springfox-spring-webmvc:jar:3.0.0:compile [INFO] | +- io.springfox:springfox-spring-webflux:jar:3.0.0:compile [INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile [INFO] | +- org.slf4j:slf4j-api:jar:1.7.30:compile [INFO] | +- org.springframework.plugin:spring-plugin-core:jar:2.0.0.RELEASE:compile [INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:2.0.0.RELEASE:compile [INFO] | +- io.swagger:swagger-annotations:jar:1.5.20:compile [INFO] | +- io.swagger:swagger-models:jar:1.5.20:compile [INFO] | - org.mapstruct:mapstruct:jar:1.3.1.Final:runtime [INFO] +- io.springfox:springfox-swagger-ui:jar:2.9.2:compile [INFO] | +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile [INFO] | +- commons-lang:commons-lang:jar:2.6:compile [INFO] | +- commons-collections:commons-collections:jar:3.2.2:compile [INFO] | +- commons-io:commons-io:jar:2.7:compile [INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile [INFO] | | - commons-logging:commons-logging:jar:1.2:compile [INFO] | +- io.jsonwebtoken:jjwt:jar:0.9.0:compile [INFO] | +- org.jasypt:jasypt:jar:1.9.2:compile [INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile [INFO] | | - org.apache.httpcomponents:httpcore:jar:4.4.14:compile [INFO] | +- org.springframework.boot:spring-boot-configuration-processor:jar:2.3.10.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.3.10.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot:jar:2.3.10.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.3.10.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.3.10.RELEASE:compile [INFO] | | | - org.slf4j:jul-to-slf4j:jar:1.7.30:compile [INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile [INFO] | | - org.yaml:snakeyaml:jar:1.26:compile [INFO] | +- org.springframework.boot:spring-boot-starter-web:jar:2.3.10.RELEASE:compile [INFO] | | - org.springframework.boot:spring-boot-starter-json:jar:2.3.10.RELEASE:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.4:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4:compile [INFO] | | - com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4:compile [INFO] | +- org.springframework.boot:spring-boot-starter-cache:jar:2.3.10.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.3.10.RELEASE:compile [INFO] | | - org.glassfish:jakarta.el:jar:3.0.3:compile [INFO] | +- org.springframework.boot:spring-boot-starter-actuator:jar:2.3.10.RELEASE:compile [INFO] | | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.3.10.RELEASE:compile [INFO] | | | - org.springframework.boot:spring-boot-actuator:jar:2.3.10.RELEASE:compile [INFO] | | - io.micrometer:micrometer-core:jar:1.5.13:compile [INFO] | | +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile [INFO] | | - org.latencyutils:LatencyUtils:jar:2.0.3:runtime [INFO] | +- org.springframework.boot:spring-boot-starter-security:jar:2.3.10.RELEASE:compile [INFO] | +- org.springframework.cloud:spring-cloud-commons:jar:2.2.5.RELEASE:compile [INFO] | +- io.pivotal.spring.cloud:spring-cloud-services-starter-config-client:jar:2.2.0.RELEASE:compile [INFO] | | +- io.pivotal.spring.cloud:spring-cloud-services-cloudfoundry-connector:jar:2.2.0.RELEASE:compile [INFO] | | | - io.pivotal.spring.cloud:spring-cloud-services-connector-core:jar:2.2.0.RELEASE:compile [INFO] | | +- io.pivotal.spring.cloud:spring-cloud-services-spring-connector:jar:2.2.0.RELEASE:compile [INFO] | | - io.pivotal.spring.cloud:cloudfoundry-certificate-truster:jar:1.0.1.RELEASE:compile [INFO] | +- io.pivotal.cfenv:java-cfenv-boot:jar:2.4.0:compile [INFO] | | +- io.pivotal.cfenv:java-cfenv:jar:2.4.0:compile [INFO] | | - io.pivotal.cfenv:java-cfenv-jdbc:jar:2.4.0:compile [INFO] | +- org.springframework.cloud:spring-cloud-config-client:jar:2.2.5.RELEASE:compile [INFO] | | - org.springframework.cloud:spring-cloud-context:jar:2.2.5.RELEASE:compile [INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.4:compile [INFO] | +- commons-codec:commons-codec:jar:1.14:compile [INFO] | +- org.jsoup:jsoup:jar:1.14.2:compile [INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile [INFO] | - org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile [INFO] +- org.springframework:spring-webmvc:jar:5.2.19.RELEASE:compile [INFO] +- org.springframework:spring-context-support:jar:3.2.8.RELEASE:compile [INFO] +- org.springframework:spring-aop:jar:5.3.7:compile [INFO] +- org.springframework:spring-beans:jar:5.2.19.RELEASE:compile [INFO] +- org.springframework:spring-context:jar:5.2.19.RELEASE:compile [INFO] +- org.springframework:spring-jcl:jar:5.2.19.RELEASE:compile [INFO] +- org.springframework:spring-expression:jar:5.2.19.RELEASE:compile [INFO] +- org.springframework:spring-web:jar:5.2.15.RELEASE:compile [INFO] +- org.springframework:spring-core:jar:5.3.7:compile [INFO] +- org.springframework.security:spring-security-config:jar:5.3.10.RELEASE:compile [INFO] +- org.springframework.security:spring-security-core:jar:5.3.10.RELEASE:compile [INFO] +- org.springframework.security:spring-security-web:jar:5.3.10.RELEASE:compile [INFO] +- org.springframework.security:spring-security-crypto:jar:5.3.10.RELEASE:compile [INFO] +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.58:compile [INFO] +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.58:compile [INFO] +- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.58:compile [INFO] +- org.apache.tomcat:tomcat-annotations-api:jar:9.0.58:compile [INFO] +- org.apache.commons:commons-lang3:jar:3.9:compile [INFO] +- junit:junit:jar:4.12:test [INFO] | - org.hamcrest:hamcrest-core:jar:2.2:test [INFO] | - org.hamcrest:hamcrest:jar:2.2:test [INFO] +- org.mockito:mockito-all:jar:1.9.5:test [INFO] +- org.hibernate.validator:hibernate-validator:jar:6.0.20.Final:compile [INFO] | +- javax.validation:validation-api:jar:2.0.1.Final:compile [INFO] | - org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile [INFO] +- nl.jqno.equalsverifier:equalsverifier:jar:3.4.1:test [INFO] +- org.projectlombok:lombok:jar:1.18.20:provided [INFO] +- org.springframework:spring-oxm:jar:3.2.8.RELEASE:compile [INFO] +- org.springframework.security.oauth:spring-security-oauth2:jar:2.3.6.RELEASE:compile [INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile [INFO] | +- org.apache.logging.log4j:log4j-web:jar:2.13.3:compile [INFO] | +- org.apache.logging.log4j:log4j-appserver:jar:2.13.3:compile [INFO] | +- com.sun.jersey:jersey-bundle:jar:1.17:compile [INFO] | | - javax.ws.rs:jsr311-api:jar:1.1.1:compile [INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.12:compile [INFO] | - javax.servlet:javax.servlet-api:jar:4.0.1:compile [INFO] +- joda-time:joda-time:jar:2.3:compile [INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.5:compile [INFO] | - log4j:log4j:jar:1.2.17:compile [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.12.2:compile [INFO] +- org.apache.logging.log4j:log4j-1.2-api:jar:2.17.1:compile [INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.11.0:compile [INFO] - com.github.ulisesbocchio:jasypt-spring-boot-starter:jar:1.18:compile [INFO] - com.github.ulisesbocchio:jasypt-spring-boot:jar:1.18:compile

pivotal-david-osullivan commented 1 year ago

This might be because you have the PCF specific connector dependencies still in your app, can you remove these? e.g.

[INFO] | +- io.pivotal.spring.cloud:spring-cloud-services-starter-config-client:jar:2.2.0.RELEASE:compile
[INFO] | | +- io.pivotal.spring.cloud:spring-cloud-services-cloudfoundry-connector:jar:2.2.0.RELEASE:compile
[INFO] | | | - io.pivotal.spring.cloud:spring-cloud-services-connector-core:jar:2.2.0.RELEASE:compile
[INFO] | | +- io.pivotal.spring.cloud:spring-cloud-services-spring-connector:jar:2.2.0.RELEASE:compile
Marveljyz commented 1 year ago

Thank you for the feedback! I worked around this issue by upgrading to these libraries: spring-boot-starter-parent:2.6.4 spring-cloud-services-dependencies: 3.4.0 spring-cloud-dependencies:2021.0.1 with other springframework library upgrades

by default, 2.6.3 and later versions drops support for cloud connector libraries and included java-cfenv support.

Marveljyz commented 1 year ago

resolved with the upgrades!