Skip to content
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

Skipping invalid classpath element jar:file:path/to/example.jar!/ #625

Closed
edeso opened this issue Jan 9, 2022 · 11 comments
Closed

Skipping invalid classpath element jar:file:path/to/example.jar!/ #625

edeso opened this issue Jan 9, 2022 · 11 comments

Comments

@edeso
Copy link

edeso commented Jan 9, 2022

we are using a custom classloader based on UrlClassLoader and for some reason in the past we needed to add jar urls in the format of

jar:file:path/to/example.jar!/

this works fine with UrlClassLoader, but ClassGraph stumbles over it with an error (see below). but actually there is no reason, as the notation is fine and simply adds 'file root inside of jar X' to the classpath. also Classgraph has no issue to filter the ClassPathElement but then refuses to scan the same later.

ClassGraph().verbose().scan() log shortened

Jan 09, 2022 7:16:52 PM nonapi.io.github.classgraph.utils.LogNode flush
INFO: 2022-01-09T19:16:51.104+0100	ClassGraph	ClassGraph version 4.8.138
2022-01-09T19:16:51.104+0100	ClassGraph	Operating system: Windows 7 6.1 amd64
2022-01-09T19:16:51.104+0100	ClassGraph	Java version: 1.8.0_242 / 1.8.0_242-b08 (AdoptOpenJDK)
2022-01-09T19:16:51.104+0100	ClassGraph	Java home: E:\Programme\jdk8u242-b08-adoptopenjdk-x64\jre
2022-01-09T19:16:51.137+0100	ClassGraph	JRE rt.jar:
2022-01-09T19:16:51.137+0100	ClassGraph	-- E:/Programme/jdk8u242-b08-adoptopenjdk-x64/jre/lib/rt.jar
2022-01-09T19:16:51.218+0100	ClassGraph	ScanSpec:
2022-01-09T19:16:51.218+0100	ClassGraph	-- packageAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- packagePrefixAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- pathAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- pathPrefixAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- classAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- classfilePathAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- classPackageAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- classPackagePathAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- moduleAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- jarAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- classpathElementResourcePathAcceptReject: 
2022-01-09T19:16:51.218+0100	ClassGraph	-- libOrExtJarAcceptReject: 
2022-01-09T19:16:51.219+0100	ClassGraph	-- scanJars: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- scanNestedJars: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- scanDirs: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- scanModules: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- enableClassInfo: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- enableFieldInfo: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- enableMethodInfo: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- enableAnnotationInfo: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- enableStaticFinalFieldConstantInitializerValues: true
2022-01-09T19:16:51.219+0100	ClassGraph	-- enableInterClassDependencies: false
2022-01-09T19:16:51.219+0100	ClassGraph	-- enableExternalClasses: false
2022-01-09T19:16:51.220+0100	ClassGraph	-- enableSystemJarsAndModules: false
2022-01-09T19:16:51.220+0100	ClassGraph	-- ignoreClassVisibility: true
2022-01-09T19:16:51.220+0100	ClassGraph	-- ignoreFieldVisibility: true
2022-01-09T19:16:51.220+0100	ClassGraph	-- ignoreMethodVisibility: true
2022-01-09T19:16:51.220+0100	ClassGraph	-- disableRuntimeInvisibleAnnotations: false
2022-01-09T19:16:51.220+0100	ClassGraph	-- extendScanningUpwardsToExternalClasses: true
2022-01-09T19:16:51.220+0100	ClassGraph	-- allowedURLSchemes: null
2022-01-09T19:16:51.220+0100	ClassGraph	-- addedClassLoaders: null
2022-01-09T19:16:51.220+0100	ClassGraph	-- overrideClassLoaders: null
2022-01-09T19:16:51.220+0100	ClassGraph	-- addedModuleLayers: null
2022-01-09T19:16:51.220+0100	ClassGraph	-- overrideModuleLayers: null
2022-01-09T19:16:51.220+0100	ClassGraph	-- overrideClasspath: null
2022-01-09T19:16:51.220+0100	ClassGraph	-- classpathElementFilters: [es.unex.sextante.openjump.Finder$1@d3e3085]
2022-01-09T19:16:51.220+0100	ClassGraph	-- initializeLoadedClasses: false
2022-01-09T19:16:51.220+0100	ClassGraph	-- removeTemporaryFilesAfterScan: false
2022-01-09T19:16:51.220+0100	ClassGraph	-- ignoreParentClassLoaders: false
2022-01-09T19:16:51.220+0100	ClassGraph	-- ignoreParentModuleLayers: false
2022-01-09T19:16:51.220+0100	ClassGraph	-- modulePathInfo: 
2022-01-09T19:16:51.221+0100	ClassGraph	-- maxBufferedJarRAMSize: 67108864
2022-01-09T19:16:51.221+0100	ClassGraph	-- enableMemoryMapping: false
2022-01-09T19:16:51.221+0100	ClassGraph	Number of worker threads: 8
2022-01-09T19:16:51.278+0100	ClassGraph	Finding classpath
2022-01-09T19:16:51.283+0100	ClassGraph	-- Finding classpath and modules
2022-01-09T19:16:51.319+0100	ClassGraph	---- Scanning of system modules is not enabled
2022-01-09T19:16:51.319+0100	ClassGraph	---- Non-system modules found:
2022-01-09T19:16:51.319+0100	ClassGraph	------ [None]
2022-01-09T19:16:51.489+0100	ClassGraph	---- Found ClassLoaders:
2022-01-09T19:16:51.489+0100	ClassGraph	------ com.vividsolutions.jump.workbench.plugin.PlugInClassLoader
2022-01-09T19:16:51.490+0100	ClassGraph	---- ClassLoaderHandlers:
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.AntClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.EquinoxClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.EquinoxContextFinderClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.FelixClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.JBossClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.WeblogicClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.WebsphereLibertyClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.WebsphereTraditionalClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.OSGiDefaultClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.SpringBootRestartClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.TomcatWebappClassLoaderBaseHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.CxfContainerClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.PlexusClassWorldsClassRealmClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.QuarkusClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.UnoOneJarClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.ParentLastDelegationOrderTestClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.JPMSClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.URLClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.ClassGraphClassLoaderHandler
2022-01-09T19:16:51.490+0100	ClassGraph	---- Finding unique classloaders in delegation order
2022-01-09T19:16:51.492+0100	ClassGraph	---- Obtaining URLs from classloaders in delegation order
2022-01-09T19:16:51.493+0100	ClassGraph	------ Classloader sun.misc.Launcher$ExtClassLoader is handled by nonapi.io.github.classgraph.classloaderhandler.URLClassLoaderHandler
2022-01-09T19:16:51.498+0100	ClassGraph	-------- Classpath element did not match filter criterion, skipping: E:/Programme/jdk8u242-b08-adoptopenjdk-x64/jre/lib/ext/access-bridge-64.jar

SNIP

2022-01-09T19:16:51.526+0100	ClassGraph	-------- Found classpath element: D:/workspace-2021.03/sextante-extension/sextante-openjump/target/sextante-openjump-2.2.0-SNAPSHOT/sextante-openjump-2.2.0-SNAPSHOT/sextante-algorithm-2.2.0-SNAPSHOT.jar
2022-01-09T19:16:51.526+0100	ClassGraph	-------- Found classpath element: D:/workspace-2021.03/sextante-extension/sextante-openjump/target/sextante-openjump-2.2.0-SNAPSHOT/sextante-openjump-2.2.0-SNAPSHOT/sextante-core-2.2.0-SNAPSHOT.jar
2022-01-09T19:16:51.526+0100	ClassGraph	-------- Found classpath element: D:/workspace-2021.03/sextante-extension/sextante-openjump/target/sextante-openjump-2.2.0-SNAPSHOT/sextante-openjump-2.2.0-SNAPSHOT/sextante-gui-2.2.0-SNAPSHOT.jar
2022-01-09T19:16:51.526+0100	ClassGraph	-------- Found classpath element: D:/workspace-2021.03/sextante-extension/sextante-openjump/target/sextante-openjump-2.2.0-SNAPSHOT/sextante-openjump-2.2.0-SNAPSHOT/sextante-math-2.2.0-SNAPSHOT.jar

SNIP

2022-01-09T19:16:51.561+0100	ClassGraph	Opening classpath elements (took 0.079626 sec)
2022-01-09T19:16:51.603+0100	ClassGraph	-- 	 [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]
2022-01-09T19:16:51.603+0100	ClassGraph	-- Skipping invalid classpath element jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-gui-2.2.0-SNAPSHOT.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-gui-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]
2022-01-09T19:16:51.603+0100	ClassGraph	-- Skipping invalid classpath element jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-algorithm-2.2.0-SNAPSHOT.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-algorithm-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]
2022-01-09T19:16:51.603+0100	ClassGraph	-- Skipping invalid classpath element jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-core-2.2.0-SNAPSHOT.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-core-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]
edeso added a commit to openjump-gis/openjump that referenced this issue Jan 9, 2022
lukehutch added a commit that referenced this issue Jan 11, 2022
@lukehutch
Copy link
Member

@edeso Thanks for the report. Can you please try again with the latest version of ClassGraph in git? I need to see what the underlying exception is that is triggering this IOException, so I improved the logging to show the underlying exception. Thanks.

@edeso
Copy link
Author

edeso commented Jan 11, 2022

here you go. you can probably debug/simulate it easily utilizing something like overrideClassLoaders(new URLClassLoader(new URL[]{ new URL("jar:file:foobar.jar!/")}))

Jan 12, 2022 12:10:23 AM nonapi.io.github.classgraph.utils.LogNode flush
INFO: 2022-01-12T00:10:23.068+0100	ClassGraph	ClassGraph version 4.8.139-SNAPSHOT
2022-01-12T00:10:23.068+0100	ClassGraph	Operating system: Windows 7 6.1 amd64
2022-01-12T00:10:23.068+0100	ClassGraph	Java version: 1.8.0_242 / 1.8.0_242-b08 (AdoptOpenJDK)
2022-01-12T00:10:23.068+0100	ClassGraph	Java home: E:\Programme\jdk8u242-b08-adoptopenjdk-x64\jre
2022-01-12T00:10:23.077+0100	ClassGraph	JRE rt.jar:
2022-01-12T00:10:23.078+0100	ClassGraph	-- E:/Programme/jdk8u242-b08-adoptopenjdk-x64/jre/lib/rt.jar
2022-01-12T00:10:23.097+0100	ClassGraph	ScanSpec:
2022-01-12T00:10:23.097+0100	ClassGraph	-- packageAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- packagePrefixAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- pathAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- pathPrefixAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- classAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- classfilePathAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- classPackageAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- classPackagePathAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- moduleAcceptReject: 
2022-01-12T00:10:23.097+0100	ClassGraph	-- jarAcceptReject: 
2022-01-12T00:10:23.098+0100	ClassGraph	-- classpathElementResourcePathAcceptReject: 
2022-01-12T00:10:23.098+0100	ClassGraph	-- libOrExtJarAcceptReject: 
2022-01-12T00:10:23.098+0100	ClassGraph	-- scanJars: true
2022-01-12T00:10:23.098+0100	ClassGraph	-- scanNestedJars: true
2022-01-12T00:10:23.098+0100	ClassGraph	-- scanDirs: true
2022-01-12T00:10:23.098+0100	ClassGraph	-- scanModules: true
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableClassInfo: true
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableFieldInfo: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableMethodInfo: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableAnnotationInfo: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableStaticFinalFieldConstantInitializerValues: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableInterClassDependencies: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableExternalClasses: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- enableSystemJarsAndModules: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- ignoreClassVisibility: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- ignoreFieldVisibility: false
2022-01-12T00:10:23.098+0100	ClassGraph	-- ignoreMethodVisibility: false
2022-01-12T00:10:23.099+0100	ClassGraph	-- disableRuntimeInvisibleAnnotations: false
2022-01-12T00:10:23.099+0100	ClassGraph	-- extendScanningUpwardsToExternalClasses: true
2022-01-12T00:10:23.099+0100	ClassGraph	-- allowedURLSchemes: null
2022-01-12T00:10:23.099+0100	ClassGraph	-- addedClassLoaders: null
2022-01-12T00:10:23.099+0100	ClassGraph	-- overrideClassLoaders: null
2022-01-12T00:10:23.099+0100	ClassGraph	-- addedModuleLayers: null
2022-01-12T00:10:23.099+0100	ClassGraph	-- overrideModuleLayers: null
2022-01-12T00:10:23.099+0100	ClassGraph	-- overrideClasspath: null
2022-01-12T00:10:23.099+0100	ClassGraph	-- classpathElementFilters: [es.unex.sextante.openjump.Finder$1@64138b0c]
2022-01-12T00:10:23.099+0100	ClassGraph	-- initializeLoadedClasses: false
2022-01-12T00:10:23.099+0100	ClassGraph	-- removeTemporaryFilesAfterScan: false
2022-01-12T00:10:23.099+0100	ClassGraph	-- ignoreParentClassLoaders: false
2022-01-12T00:10:23.099+0100	ClassGraph	-- ignoreParentModuleLayers: false
2022-01-12T00:10:23.099+0100	ClassGraph	-- modulePathInfo: 
2022-01-12T00:10:23.100+0100	ClassGraph	-- maxBufferedJarRAMSize: 67108864
2022-01-12T00:10:23.100+0100	ClassGraph	-- enableMemoryMapping: false
2022-01-12T00:10:23.100+0100	ClassGraph	Number of worker threads: 8
2022-01-12T00:10:23.120+0100	ClassGraph	Finding classpath
2022-01-12T00:10:23.122+0100	ClassGraph	-- Finding classpath and modules
2022-01-12T00:10:23.137+0100	ClassGraph	---- Scanning of system modules is not enabled
2022-01-12T00:10:23.137+0100	ClassGraph	---- Non-system modules found:
2022-01-12T00:10:23.138+0100	ClassGraph	------ [None]
2022-01-12T00:10:23.169+0100	ClassGraph	---- Found ClassLoaders:
2022-01-12T00:10:23.169+0100	ClassGraph	------ com.vividsolutions.jump.workbench.plugin.PlugInClassLoader
2022-01-12T00:10:23.169+0100	ClassGraph	---- ClassLoaderHandlers:
2022-01-12T00:10:23.169+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.AntClassLoaderHandler
2022-01-12T00:10:23.169+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.EquinoxClassLoaderHandler
2022-01-12T00:10:23.169+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.EquinoxContextFinderClassLoaderHandler
2022-01-12T00:10:23.169+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.FelixClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.JBossClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.WeblogicClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.WebsphereLibertyClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.WebsphereTraditionalClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.OSGiDefaultClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.SpringBootRestartClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.TomcatWebappClassLoaderBaseHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.CxfContainerClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.PlexusClassWorldsClassRealmClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.QuarkusClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.UnoOneJarClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.ParentLastDelegationOrderTestClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.JPMSClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.URLClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	------ nonapi.io.github.classgraph.classloaderhandler.ClassGraphClassLoaderHandler
2022-01-12T00:10:23.170+0100	ClassGraph	---- Finding unique classloaders in delegation order
SNIP
2022-01-12T00:10:23.225+0100	ClassGraph	Opening classpath elements (took 0.027225 sec)
2022-01-12T00:10:23.234+0100	ClassGraph	-- Skipping invalid classpath element jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-algorithm-2.2.0-SNAPSHOT.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-algorithm-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd] : nonapi.io.github.classgraph.concurrency.SingletonMap$NewInstanceException: newInstance threw an exception for key jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-algorithm-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]
2022-01-12T00:10:23.234+0100	ClassGraph	-- Skipping invalid classpath element jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-core-2.2.0-SNAPSHOT.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-core-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd] : nonapi.io.github.classgraph.concurrency.SingletonMap$NewInstanceException: newInstance threw an exception for key jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-core-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]
2022-01-12T00:10:23.234+0100	ClassGraph	-- Skipping invalid classpath element jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-gui-2.2.0-SNAPSHOT.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-gui-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd] : nonapi.io.github.classgraph.concurrency.SingletonMap$NewInstanceException: newInstance threw an exception for key jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-gui-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]
2022-01-12T00:10:23.234+0100	ClassGraph	-- Skipping invalid classpath element jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-math-2.2.0-SNAPSHOT.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-math-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd] : nonapi.io.github.classgraph.concurrency.SingletonMap$NewInstanceException: newInstance threw an exception for key jar:file:D:\workspace-2021.03\sextante-extension\sextante-openjump\target\sextante-openjump-2.2.0-SNAPSHOT\sextante-openjump-2.2.0-SNAPSHOT\sextante-math-2.2.0-SNAPSHOT.jar!/ [com.vividsolutions.jump.workbench.plugin.PlugInClassLoader@659e0bfd]

@lukehutch
Copy link
Member

I didn't try to reproduce this previously because you said it only happens with your custom classloader, not with URLClassLoader. I just tried your suggestion of how to reproduce it, and I can't get this reproduction to work.

I just checked in an additional layer of exception logging. Can you please generate the log one more time with the latest version?

@lukehutch
Copy link
Member

And/or can you please upload a minimal reproducer project?

lukehutch added a commit that referenced this issue Jan 12, 2022
@lukehutch
Copy link
Member

I just committed a possible fix, but I have no way to test this without being able to reproduce the issue, so this is all guesswork...

@edeso
Copy link
Author

edeso commented Jan 12, 2022

actually stripping isn't a proper solution, as the url might contain a path/file entry within the jar e.g.

A Jar entry
jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class
A Jar file
jar:http://www.foo.com/bar/baz.jar!/
A Jar directory
jar:http://www.foo.com/bar/baz.jar!/COM/foo/

from https://docs.oracle.com/javase/8/docs/api/java/net/JarURLConnection.html

here's a quick test that verbosely shows the issue against one of your test jars
edeso@127ccef
.
when run it sports now (after the spec stripping)

2022-01-12T15:10:58.769+0100 ClassGraph -- Skipping invalid classpath element jar:file:issue209.jar!/ : java.io.IOException: Cannot get classpath element for classpath entry jar:file:issue209.jar!/ [java.net.URLClassLoader@51c8530f] : nonapi.io.github.classgraph.concurrency.SingletonMap$NewInstanceException: newInstance threw an exception for key jar:file:issue209.jar!/ [java.net.URLClassLoader@51c8530f] : java.io.IOException: Cannot handle URL file:issue209.jar!/ : URI is not hierarchical

@edeso
Copy link
Author

edeso commented Jan 12, 2022

also i seem to recall the proper way to parse jar:file: urls is to actually open a connection and work with the resulting JarUrlConnection, something like this
https://stackoverflow.com/a/402771

@lukehutch
Copy link
Member

Sorry for the delay, I have been traveling with very little downtime.

ClassGraph doesn't use JarUrlConnection or anything similar to that, because the underlying Java ZipFile API is single-threaded (protected by a synchronized public API). So stripping jar: and file: off the beginning is totally fine. It just has to be added back on again if a Resource's URL is requested. Internally ClassGraph recognizes ! in a jar's path as a separator, and it actually works to arbitrary levels of depth (ClassGraph implements a very fast zipfile central directory parser that can access zip entries within zipfiles that are embedded (stored) within other zipfiles).

I will try to run your testcase in the next few days once I can make more time -- thanks for providing that!

@edeso
Copy link
Author

edeso commented Feb 14, 2022

yeah, the mentioning of JarUrlConnection was merely to point it that it might be more difficult. not sure you want to dig in to this corner case, but if i recall correctly could the url be stacked as well (not sure there is a depth limit). e.g.

jar:http://www.foo.com/bar/baz.jar!/COM/foo/yetanother.jar!/

reading as the zip root of yetanother.jar, which is located in baz.jar under '/COM/foo/', which in turn is located on 'http://www.foo.com/bar/' . aren't Jar-Urls fun ;)

@lukehutch
Copy link
Member

Hi, I checked the example code you linked (thank you for providing this). The call Paths.get(classpathEntryURL.toURI()) does indeed fail for a URL of jar:file:issue209.jar!/, with jar: stripped. I removed the stripping of jar: since I agree that it is not needed here.

However, this call also fails for an input URL of jar:file:issue209.jar!/, with the same error message of java.lang.IllegalArgumentException: URI is not hierarchical. The failure happens in Paths.get. In other words, the error can be reproduced by simply calling new URL("jar:file:issue209.jar!/").toURI().

I fixed this by trying URL -> URI -> Path, followed by URL -> File -> Path, followed by URL -> toString() -> FastPathResolver.resolve() -> Paths.get. One of these should succeed always, for a valid URL.

Fixed and released in 4.8.141. Thank you for this bug report, and for your patience!

@edeso
Copy link
Author

edeso commented Feb 26, 2022

hmm, little brute force for my taste, but your project, your style.

also, be aware. you actually the whole archive (root dir) to the index, but the url might be as well jar:file:issue209.jar!/some/sub/folder/only/ .

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants