javanullpointerexceptionapache-commons

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


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.


Solution

  • 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.