How to fix NullPointerException "org.apache.commons.lang3.SystemUtils.JAVA_SPECIFICATION_VERSION_AS_ENUM" is null?
Asked Answered
C

3

7

I keep trying to run my code, but when I run it I get the message

"Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.commons.lang3.JavaVersion.atLeast(org.apache.commons.lang3.JavaVersion)" because "org.apache.commons.lang3.SystemUtils.JAVA_SPECIFICATION_VERSION_AS_ENUM" is null"

Anyone know how to fix this? I appreciate the help.

Cyrstalcyrus answered 3/12, 2020 at 0:45 Comment(1)
Please provide a full stack trace that shows this happens in SystemUtils.isJavaVersionAtLeast.Scuba
G
5

You're on an old version of lang3 which does not recognize the Java version you are on. More recent versions are trying to dance around the fact that hard crashing when a new java version is released was always rather daft, but more so when a new java release is available every 6 months, but evidently the version of lang3 you have predates this upgrade.

More generally, don't use apache commons libraries unless you have a very pressing need; they are not particularly good API designs. But, if you must, all you really need to do is update your version dep to the most recent. version 3.11 should do the trick.

Garish answered 3/12, 2020 at 0:51 Comment(4)
Thank you for the answer! By version dep, are you talking about in the pom.xml file? I looked through my file and my whole project for that matter, and couldn't find where I was using that library.Cyrstalcyrus
Yes. It is possible some other library you use, depends on it. There are tools to find all the deps that maven is pulling in; try adding the lang3 dep to your pom, at v 3.11.Garish
This was the problem, but for me the solution was to upgrade maven-surefire-plugin version.Ilex
can you share the working pom.Metastasis
D
0

Try downgrading java in enviromental variables %JAVA_HOME% and Path, 1.8 should be enough

Dearr answered 4/10, 2023 at 21:52 Comment(0)
J
0

In my case i am using "com.github.jhonnymertz:java-wkhtmltopdf-wrapper:1.3.0-RELEASE" which is based on lang3:3.14.0, so i excluded it and implemented a lower version of lang3:

implementation 'org.apache.commons:commons-lang3:3.11'

implementation('com.github.jhonnymertz:java-wkhtmltopdf-wrapper:1.3.0-RELEASE') {
    exclude group: 'org.apache.commons', module: 'commons-lang3'
}
Jylland answered 25/4, 2024 at 11:9 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.