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.

Not Finding Classpath Elements on Java 11

See original GitHub issue

I’m using ClassGraph 4.8.53 and having a problem with Java 11 not finding classpath elements but it’s working on Java 8.

Here is what I’m seeing on Java 11:

2019-11-17T08:01:56.968-0700	ClassGraph	Finding classpath
2019-11-17T08:01:56.968-0700	ClassGraph	-- Finding classpath and modules
2019-11-17T08:01:56.969-0700	ClassGraph	---- Found ClassLoaders:
2019-11-17T08:01:56.969-0700	ClassGraph	------ jdk.internal.loader.ClassLoaders$AppClassLoader
2019-11-17T08:01:56.969-0700	ClassGraph	---- Overriding classpath with: jdk.internal.loader.ClassLoaders$AppClassLoader@77556fd
2019-11-17T08:01:56.969-0700	ClassGraph	------ Found classpath element: jdk.internal.loader.ClassLoaders$AppClassLoader@77556fd -> /home/jw/projects/webjars/webjars-play/jdk.internal.loader.ClassLoaders$AppClassLoader@77556fd
2019-11-17T08:01:56.969-0700	ClassGraph	------ WARNING: when the classpath is overridden, there is no guarantee that the classes found by classpath scanning will be the same as the classes loaded by the context classloader
2019-11-17T08:01:56.969-0700	ClassGraph	-- Module scanning is disabled, because classloaders or classpath was overridden
2019-11-17T08:01:56.970-0700	ClassGraph	Opening classpath elements (took 0.026549 sec)
2019-11-17T08:01:56.970-0700	ClassGraph	-- Skipping invalid classpath element /home/jw/projects/webjars/webjars-play/jdk.internal.loader.ClassLoaders$AppClassLoader@77556fd : java.io.FileNotFoundException
2019-11-17T08:01:56.996-0700	ClassGraph	Finding nested classpath elements
2019-11-17T08:01:56.996-0700	ClassGraph	Final classpath element order:
2019-11-17T08:01:56.997-0700	ClassGraph	Scanning classpath elements (took 0.000006 sec)
2019-11-17T08:01:56.997-0700	ClassGraph	Classfile scanning is disabled

This seems to only be a problem when I call overrideClassLoaders(classLoader). If I call getResources on the classloader I can see everything I’m looking for.

Sorry I don’t understand much about how the classpath stuff might have changed in Java 11.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
lukehutchcommented, Apr 1, 2020

The fix for this was incomplete, see #411. The full fix is in git master, and will be released in 4.8.67 (might take a few days to hit Maven Central, because Sonatype is currently having issues).

1reaction
lukehutchcommented, Nov 18, 2019

You’re welcome, that’s the goal! I try to maintain this project how I wish all open source software was maintained. (This is the software version of The Golden Rule 😃 )

The change I just checked in catches one additional case – it also enables system module scanning if you override the classloaders with the parent of an AppClassLoader, which is a PlatformClassLoader (which only loads classes for system modules).

It’s a simple enough change that I’ll just cross my fingers and hope it works 😄 Released in 4.8.54. You should be able to revert your latest change and just depend upon this version to fix the problem.

Thanks for your report!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I discover what all jars are on my classpath in Java ...
I'm attempting to use VS Code to run some unit tests in my solution. When I do, I get the following error: java.lang....
Read more >
PATH and CLASSPATH (The Java™ Tutorials > Essential ...
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable ......
Read more >
Transition from Java 8 to Java 11 - Azure - Microsoft Learn
The symptom of a split-package problem is that a class you know to be on the class-path is not found. This issue will...
Read more >
3 ways to solve java.lang.NoClassDefFoundError in Java J2EE
google.common.base.Function, which is likely from Google's Guava library but not able to found in your application's classpath. Please add guava-18.0.jar into ...
Read more >
Dependencies and Class Loading - Jenkins
If you are not a Java developer, you can get away with ignoring all this ... to determine the initiating ClassLoader ; since...
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