question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoClassDefFoundError when using 1.0 M2 with Spring Data REST 3.1

See original GitHub issue

Below is my gradle configuration:

apply from: "$rootDir/gradle/spring-boot-app.gradle"

configurations {
    compile.exclude module: 'spring-boot-starter-logging'
}

repositories {
    maven { url "https://repo.spring.io/milestone" }
}
dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.springframework.boot:spring-boot-starter-webflux'
    implementation 'org.springframework.hateoas:spring-hateoas:1.0.0.M2'
    compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
    compile group: 'org.springframework.data', name: 'spring-data-rest-hal-browser', version: '3.1.9.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-data-cassandra-reactive'
    implementation "com.yugabyte:cassandra-driver-core:${yugabyteCassandraDriverVersion}"
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.9'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9.2'
    compile group: 'org.projectlombok', name: 'lombok', version: '0.11.0'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version: '2.1.7.RELEASE'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'io.projectreactor:reactor-test'
}

Getting below runtime exception:

2019-08-08 20:34:11,245 WARN o.s.b.SpringApplication [main] Unable to close ApplicationContext
java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@68be2bc2]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:507) ~[spring-core-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:404) ~[spring-core-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:389) ~[spring-core-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:447) ~[spring-core-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[?:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:738) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:679) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:647) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1518) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:509) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:479) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:600) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:592) ~[spring-beans-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1226) ~[spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:905) ~[spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:891) ~[spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:877) ~[spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:826) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
	at com.ericsson.ddm3.digitaltwinruntime.DigitalTwinRuntimeApplication.main(DigitalTwinRuntimeApplication.java:11) [classes!/:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [digital-twin-runtime-0.0.1-SNAPSHOT.jar:?]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [digital-twin-runtime-0.0.1-SNAPSHOT.jar:?]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [digital-twin-runtime-0.0.1-SNAPSHOT.jar:?]
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [digital-twin-runtime-0.0.1-SNAPSHOT.jar:?]
Caused by: java.lang.NoClassDefFoundError: org/springframework/hateoas/mvc/UriComponentsContributor
	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[?:?]
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[?:?]
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:550) ~[?:?]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:458) ~[?:?]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:452) ~[?:?]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
	at java.net.URLClassLoader.findClass(URLClassLoader.java:451) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[digital-twin-runtime-0.0.1-SNAPSHOT.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:?]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:3166) ~[?:?]
	at java.lang.Class.getDeclaredMethods(Class.java:2309) ~[?:?]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489) ~[spring-core-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	... 29 more
Caused by: java.lang.ClassNotFoundException: org.springframework.hateoas.mvc.UriComponentsContributor
	at java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[digital-twin-runtime-0.0.1-SNAPSHOT.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[?:?]
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[?:?]
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:550) ~[?:?]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:458) ~[?:?]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:452) ~[?:?]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
	at java.net.URLClassLoader.findClass(URLClassLoader.java:451) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[digital-twin-runtime-0.0.1-SNAPSHOT.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:?]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:3166) ~[?:?]
	at java.lang.Class.getDeclaredMethods(Class.java:2309) ~[?:?]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489) ~[spring-core-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
	... 29 more

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SamDcommented, Oct 25, 2019

This is likely the inclusion of springfox, I’m seeing that as well that lead me here

+--- io.springfox:springfox-data-rest:2.9.2
|    +--- org.springframework.data:spring-data-rest-webmvc:2.6.13.RELEASE -> 3.2.0.RELEASE (*)

And apparently for some bizarre reason, api documentation isn’t a priority for Spring Data Rest

https://github.com/springdoc/springdoc-openapi/issues/125#issuecomment-546166391

0reactions
odrotbohmcommented, Oct 25, 2019

Just to set this straight:

api documentation isn’t a priority for Spring Data Rest

This is not the case. The ticket linked to, states the opposite: Spring Data REST doesn’t seem to be a priority to the springdoc team. Note, that springdoc has nothing to do with the Spring team whatsoever.

That said, I acknowledge that Spring Data REST’s design philosophy is slightly at odds with what Swagger/OpenAPI does. We primarily focus on hypermedia, which – at least historically – has been deliberately out of scope for the Swagger/OpenAPI world. We expose dynamic payload metadata at runtime and theres Spring RESTDocs support for testing hypermedia APIs and generating documentation from those tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jpa - java.lang.NoClassDefFoundError while running spring ...
My advice: stop using the spring snapshot repo, and stick to final release versions. Also, use compatible versions: you're using spring-data-rest-core 2.3.2 ...
Read more >
Spring Boot, Maven and Eclipse Errors and TroubleShooting ...
Consider defining a bean of type 'CustomerDAO' in your configuration. Error : Detached object passed to persist; Error : java.lang.
Read more >
Spring Boot Reference Documentation
Try the How-to documents. They provide solutions to the most common questions. Learn the Spring basics. Spring Boot builds on many other Spring...
Read more >
3 ways to solve java.lang.NoClassDefFoundError in Java J2EE
I know how frustrating is to see Exception in thread "main" java.lang.NoClassDefFoundError, which is a manifestation of NoClassDefFoundError in Java.
Read more >
Build RESTful Service in Java using JAX-RS and Jersey ...
Write a java REST service to convert Fahrenheit to Celsius and Celcius to. ... java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found