Exception in Apache StringUtils

King Aslan picture King Aslan · Mar 28, 2012 · Viewed 11.6k times · Source

hello guys i am try to use the StringUtils.remove Method but the below exception is raising i have include the jar file and StringUtils.lowercase and String.countsMatches is working only remove is not what may be the problem

<%@page import="org.apache.commons.lang.StringUtils"%>

this is how i imported and the exception is as follows

java.lang.NoSuchMethodError:
org.apache.commons.lang.StringUtils.remove(Ljava/lang/String;Ljava/lang/String;)
Ljava/lang/String;

Answer

Christian Semrau picture Christian Semrau · Mar 31, 2012

The remove(String,String) method was added to version 2.1 of commons-lang. It is not present in 2.0 and earlier.

Depending on which Servlet Container or Application Server you use (and which version of it), the server class path may contain an outdated version of commons-lang, which is used instead of your copy of commons-lang in the applications /lib folder. If that's your problem, you can configure your application to prefer the application class path, instead of the server class path.