-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Provide some guidance on identifying and resolving Devtools classloading issues #29438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
wilkinsona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @aahlenst. I've made some comments for your consideration when you have a moment.
spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/devtools.adoc
Outdated
Show resolved
Hide resolved
| To do so, you can create a `META-INF/spring-devtools.properties` file. | ||
| The same is true if you use `mvn spring-boot:run` or `gradle bootRun` in a multi-module project: The project containing your `@SpringBootApplication` is loaded with the "`restart`" classloader, and everything else with the "`base`" classloader. | ||
|
|
||
| To instruct Spring Boot to load `.jar` files with a different classloader, you can create a `META-INF/spring-devtools.properties` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this is needed. If it is, I think it should be part of the next paragraph rather than in a paragraph of its own.
| These might manifest in an exception like: | ||
|
|
||
| [source,text] | ||
| ---- | ||
| Caused by: java.lang.IllegalArgumentException: non-public interface is not defined by the given loader | ||
| ---- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not in favour of specifically mentioning IllegalArgumentException here. Unfortunately, class loading issues can appear in many different ways. Mentioning one specifically is likely to do more harm than good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's less about the IllegalArgumentException and more about the error message itself. Recently, I was called in to troubleshoot exactly this problem. At first I was stumped because the application ran fine in the IDE and when packaged. It took me a lot of time to figure out what the problem was. Feeding the error message to search engines didn't yield good results, either.
Do you have an idea how to make this easier to discover without misleading people that have other classloading problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid not. It's a shame that the JDK uses "loader" rather than the arguably less ambiguous "class loader" as that may help to point people in the right direction.
The docs on DevTools currently mention "classloading issues" but don't really expand on how to diagnose them. Rather than trying to list specific failures that may be a classloading issue, I think it would be better to point people towards completely disabling restart as a way of identifying if the split class loader is the cause.
If you encounter the problem of the two classloaders in Devtools, there's no hint that there are two classloaders and that some configuration changes might help you. You only get an IllegalArgumentException. Googling does not help because the exception is not mentioned in the docs. Futhermore, the docs sound like the problem can only occur in IDEs, which is not the case.
de04aa6 to
243cf42
Compare
|
@wilkinsona I reworked my PR. There's now a separate section about diagnosing classloading issues incl. an admonition block that points out that devtools might cause them. |
If you encounter the problem of the two classloaders in Devtools, there's no hint that there are two classloaders and that some configuration changes might help you. You only get an IllegalArgumentException. Googling does not help because the exception is not mentioned in the docs. Futhermore, the docs sound like the problem can only occur in IDEs, which is not the case.