We are having a spring boot application and trying to start from within IDEA IntelliJ in relationship with JPA classes we are getting the following exception:
(package names are dummies):
java.lang.ClassCastException: class jpa.XVersion cannot be cast to class jpa.XVersion (jpa.XVersion is in unnamed module of loader 'app'; jpa.XVersion is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @671ef14f)
at y.package.abc(XService.java:70)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
If we remove the dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
and restart from inside the IDE it works fine.
Running the application from plain command line the application is running without any exception.
The solution currently to remove the devtools while working within the IDE.
Environment: * Spring Boot Version 2.3.1 * JDK 11 (Adopt OpenJDK 11.0.7) * IDEA IntelliJ * Apache Maven 3.6.3
We are not using an module-info.java
.
At the moment I'm not 100% sure if this a problem of the spring-boot-devtools or the IDE?
https://stackoverflow.com/questions/62575769/java-lang-classcastexception-class-is-in-unnamed-module-of-loader-app-s
Comment From: wilkinsona
Spring Boot's DevTools splits things into two ClassLoaders, the default app class loader and a restart class loader. You can learn more about this in the documentation. From what you've described thus far, it sounds like you have a class loading problem where something is make an assumption about the class loader to use that does not hold true with DevTools' two class loaders. You may be able to avoid the problem by customizing the restart class loader.
If the above doesn't help and you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: khmarbaise
First thanks @wilkinsona for the information. I will take a deeper look into that within the next days.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.