File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ClassNotFoundException: org.apache.commons.lang.StringUtils" Watch "ClassNotFoundException: org.apache.commons.lang.StringUtils" New topic
Author

ClassNotFoundException: org.apache.commons.lang.StringUtils

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Hi

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

message

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

exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
com.example.servlets.ChannelList.doGet(ChannelList.java:66)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

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.

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