I got an automatic dependency update PR which failed. Should v4.1.0 spotbugs work with v4.0.x maven plugin?
Linked to PR 1236
If that combination is due to work, then keep reading;
[java] Error: A JNI error has occurred, please check your installation and try again
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
[java] at java.lang.Class.getDeclaredMethods0(Native Method)
[java] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
[java] at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
[java] at java.lang.Class.getMethod0(Class.java:3018)
[java] at java.lang.Class.getMethod(Class.java:1784)
[java] at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
[java] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
[java] Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[java] ... 7 more
I've got this in my pom.xml;
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.0.4</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.1.0</version>
</dependency>
</dependencies>
</plugin>
4.1.0 depends on dom4j in compile scope as expected:
https://repo1.maven.org/maven2/com/github/spotbugs/spotbugs/4.1.0/spotbugs-4.1.0.pom
Could you rerun the build? If it reproduce the problem, try to share a mcve project.
Although not original reporter of this issue, I do experience the same. Here is simple reproducer that fails on spotbugs upgrade, while working with 4.0.6.
It also presents the warning of invalid POM mentioned in https://github.com/spotbugs/spotbugs-maven-plugin/issues/243.
@KengoTODA so from you response I assume you expect spotbugs-maven-plugin v4.0.4 to work with spotbugs v4.1.0.
With more debug I'm seeing this;
[INFO] --- spotbugs-maven-plugin:4.0.4:spotbugs (spotbugs) @ PROJECT ---
[WARNING] The POM for com.github.spotbugs:spotbugs:jar:4.1.0 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for com.github.spotbugs:spotbugs:4.1.0
[ERROR] 'dependencies.dependency.version' for org.apache.commons:commons-lang3:jar is missing. @
If I add the following to my project
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
Then spotbugs passes, but I would expect spotbugs to declare what version it needs of dependencies.
Working on MRE and will share soon.
Ah... I see. It seems that the change in the following commit broke the POM even though it works in the Gradle world.
https://github.com/spotbugs/spotbugs/commit/a5a42876d2c46a170526c34429ad814f0ce82c67#diff-cd608fd23317adb8f92f6e8382ccc7b4
I'll propose a fix later, and ship 4.1.1. Thanks for your help!
If you still need it, the MRE is here https://github.com/nhojpatrick/com.github.spotbugs_v4.1.0_plugin_v4.0.4
SpotBugs 4.1.1 is out. Could you have a try with it?
https://repo1.maven.org/maven2/com/github/spotbugs/spotbugs/4.1.1/
@KengoTODA - 4.1.1 works for my projects - thank you for super fast release!
Also checked @nhojpatrick's reproducer - it's fine now as well.
v4.1.1 works for me too.