File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassNotFoundException: org.apache.commons.lang.StringUtils

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 518
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic