Skip to content

Conversation

@aahlenst
Copy link
Contributor

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 16, 2022
Copy link
Member

@wilkinsona wilkinsona left a 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.

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.
Copy link
Member

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.

Comment on lines 220 to 225
These might manifest in an exception like:

[source,text]
----
Caused by: java.lang.IllegalArgumentException: non-public interface is not defined by the given loader
----
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.
@aahlenst aahlenst force-pushed the classloader-devtools branch from de04aa6 to 243cf42 Compare January 18, 2022 16:40
@aahlenst
Copy link
Contributor Author

@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.

@wilkinsona wilkinsona changed the title Make classloader customization easier to discover Provide some guidance on identifying and resolving Devtools classloading issues Jan 19, 2022
@wilkinsona wilkinsona added this to the 2.5.x milestone Jan 19, 2022
@wilkinsona wilkinsona added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 19, 2022
@snicoll snicoll self-assigned this Jan 31, 2022
@snicoll snicoll modified the milestones: 2.5.x, 2.5.10 Jan 31, 2022
snicoll pushed a commit that referenced this pull request Jan 31, 2022
@snicoll snicoll closed this in f60af4d Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: documentation A documentation update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants