spotbugs / spotbugs-gradle-plugin

https://plugins.gradle.org/plugin/com.github.spotbugs
Apache License 2.0
180 stars 68 forks source link

[5.0.0] java.lang.ClassNotFoundException: org.apache.commons.lang.IllegalClassException #633

Open boris-petrov opened 2 years ago

boris-petrov commented 2 years ago

Using SpotBugs 4.5.0 and the Gradle plugin version 5.0.0. After updating to it, I started getting:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/IllegalClassException
        at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3373)
        at java.base/java.lang.Class.getConstructor0(Class.java:3578)
        at java.base/java.lang.Class.getConstructor(Class.java:2271)
        at edu.umd.cs.findbugs.DetectorFactory$ReflectionDetectorCreator.createDetector(DetectorFactory.java:78)
        at edu.umd.cs.findbugs.DetectorFactory$ReflectionDetectorCreator.createDetector2(DetectorFactory.java:103)
        at edu.umd.cs.findbugs.DetectorFactory.createDetector2(DetectorFactory.java:396)
        at edu.umd.cs.findbugs.plan.AnalysisPass.instantiateDetector2sInPass(AnalysisPass.java:132)
        at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1024)
        at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:309)
        at edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:395)
        at edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1231)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.IllegalClassException
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 12 more

I am using the Monits FindBugs plugin (spotbugsPlugins 'com.monits:findbugs-plugin:0.2.0@jar') and it is the cause for that. Any ideas how to fix it?

boris-petrov commented 1 year ago

I believe this is working with the latest version of the Gradle plugin. Thanks!

boris-petrov commented 1 year ago

5.1.1 broke it again. :smile: I guess because 5.1.0 didn't load any plugins.

KengoTODA commented 1 year ago

It seems that it's a problem on the plugin side, its manifest file has no Class-Path attribute so it could not find dependencies.

boris-petrov commented 1 year ago

It's a very old plugin, yes. I guess it is a problem in it. However, is there something that can be done on SpotBug's side to support that? If not, I would totally understand.