javaantbuild.xml

Upgrading the commons-lang-2.6.jar throws NoClassDefFoundError


enter image description hereI have upgraded the version of commons-lang from 'commons-lang-2.6.jar' to 'commons-lang3-3.2.1.jar'. After deployment when I goes to test particular link it throws "SEVERE: >>java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils". I have upgraded the Jar for Swagger compatability. I am using ant build, all these dependencies are declared in 'build.xml' and libraries are added in lib folder.


Solution

  • The base package of Apache Commons Lang 3 is not org.apache.commons.lang anymore.

    Provided that the error occurs in your own code, you have to replace it with the org.apache.commons.lang3 package .

    If it occurs in external libraries, either upgrade them to a version that uses Lang 3 (if it is possible), or you may have to also keep your older commons lang among the dependencies (as explained in the answer by Karol, the distinct packages will prevent possible conflicts anyway).

    e.g :

    org.apache.commons.lang.StringUtils in Lang 2.6

    vs

    org.apache.commons.lang3.StringUtils in Lang 3