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.

Class loading is broken with Spring Boot's DevTools again.

See original GitHub issue

Hello Luke,

Sadly #331 introduced a regression of #267.

That became apparent in a change of Neo4j-OGM where we now rely on ClassGraph being able to find scanned classes.

Find attached a reproducer:

try(ScanResult r = new ClassGraph()
			.ignoreClassVisibility()
			.whitelistPackages("com.example.gh729.domain")
			.scan()) {

			for(ClassInfo classInfo : r.getAllClasses()) {
				if("com.example.gh729.domain.SomeClass".equals(classInfo.getName())) {
					SomeClass f = (SomeClass) classInfo.loadClass().getConstructor().newInstance();
				}
			}
		}

This works in 4.8.17 and starts to fail in 4.8.19 again (as before my contribution).

This is the expected order of class loaders withorg.springframework.boot.devtools.restart.classloader.RestartClassLoader present

image

This is now what I get in 4.8.19+

image

Both screenshots from debugging into io.github.classgraph.ClassGraphClassLoader and displaying the order of class loaders used.

Find the reproducer attached. Open in your IDE and run Gh729Application.

gh729.zip

Related OGM ticket is https://github.com/neo4j/neo4j-ogm/issues/729

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
lukehutchcommented, Jan 8, 2020

Actually now that I understand the Restart classloader better, I made some further cleanups to simplify the ClassLoaderHandler in the last commit. Please check also that 4.8.61-SNAPSHOT (the git master version) works for you in addition to 4.8.60. (The master version should also work fine.)

1reaction
michael-simonscommented, Jan 8, 2020

Great work, Luke! I can confirm both 4.8.60 and 4.8.61-SNAPSHOT works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - spring-boot-devtools causing ClassCastException while ...
This is a known limitation of Devtools. When the cache entry is deserialized, the object is not attached to the proper classloader.
Read more >
IntelliJ IDEA Fix Spring Boot DevTools not working - YouTube
How to fix the problem of Spring Boot DevTools not working in IntelliJ IDEA: automatic restart does not trigger and changes to static ......
Read more >
Developing with Spring Boot
If your application is launched from java -jar or if it is started from a special classloader, then it is considered a “production...
Read more >
Fixing classloader problems with Spring Devtools ... - Life in IDE
While for RedissonNode the class loader is AppClassLoader what's one level up before RestartClassLoader (it's RestartClassLoader.getParent() ).
Read more >
Spring Boot - Tutorial - Vogella.com
Create a new package with the name com.vogella.spring.issues.controller in the src/main/java folder. In there, create the following Class IssueController .
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