Reputation: 213
Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader
at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:93)
at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56)
at org.springframework.boot.devtools.restart.Restarter.<init(Restarter.java:138)
at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:537)
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartedEvent(RestartApplicationListener.java:68)
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:45)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:63)
at org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:304)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
at com.rme.hub.RmeApplication.main(RmeApplication.java:24)
Upvotes: 16
Views: 102275
Reputation: 661
Check your JAVA_HOME in hadoop-env.sh. Changing my JAVA_HOME value in $HADOOP_HOME/etc/hadoop with java 8 (export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
) value in the hadoop-env.sh solved this issue for me.
I had a higher java version defined in my hadoop-env.sh
value when I had defined java 8 in my .bashrc file. So keeping both the same java 8 version fixed the issue for me.
Upvotes: 0
Reputation: 61
I had this problema on eclipse and had solved by doing these step:
That is all! Hope it will be useful for you.
Upvotes: 4
Reputation: 1
solution: change JDK version 8 in your IDE
I got the same issue in the spring boot application in IntelliJ idea and sts but I found one solution in that issue :
if you are using AD integration in your project with it belongs to Microsoft, then you need to use java 8 version JDK because currently Microsoft AD plugins are not supported to java 9 or higher version it will support only the java 8 or lower version
Upvotes: 0
Reputation: 116111
Judging by the presence of java.base/jdk.internal.loader.ClassLoaders
in the stack trace, you are using Java 9 or later. Spring Boot's DefaultRestartInitializer
is trying to cast the app class loader to a URLClassLoader
. This works in Java 8 and earlier but does not work with Java 9 or later. Spring Boot had been updated in 2.0 to cope with this change in Java 9.
If you want to use Spring Boot with Java 9 or later, you should upgrade to Spring Boot 2. At the time of writing, the latest release is 2.0.5 which supports Java 8, 9, and 10. Spring Boot 2.1, which will be released later this year, will add support for Java 11.
Upvotes: 49