wood burning stoves 2.0
The moose likes Java in General and the fly likes ClassNotFoundException: org.apache.commons.lang.StringUtils Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ClassNotFoundException: org.apache.commons.lang.StringUtils" Watch "ClassNotFoundException: org.apache.commons.lang.StringUtils" New topic

ClassNotFoundException: org.apache.commons.lang.StringUtils

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518

I am having the jar file "commons-lang-2.1.jar" in my project's libraries.When i use

String str=r.getEvents().toString();
int count=StringUtils.countMatches(str,"org.asteriskjava.manager.event.StatusEvent");

in java application,it works well.But when i use the same in a servlet program in the same project ,the following error occurs:

type Exception report


description The server encountered an internal error () that prevented it from fulfilling this request.

javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.

If any one wants to paste my code,i will do that.please help me to solve this.

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
First of all: a NoClassDefFoundError is not to be confused with ClassNotFoundException.

Regarding to your actual problem: the error is pretty self-explaining. The mentioned class is missing in the runtime classpath. To fix this, just place the JAR file with the class in the classpath of the webapplication, which by default covers under each the /WEB-INF/lib folder.
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Thanks for you reply.As you told i have placed the jar file in WEB-INF/lib folder and now it is working
I agree. Here's the link: http://aspose.com/file-tools
subject: ClassNotFoundException: org.apache.commons.lang.StringUtils
jQuery in Action, 3rd edition