Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Tomcat's commons-digester.jar in Servlet

 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have a servlet which uses the Digester class. Now, when running in the Tomcat container, I get a ClassNotFoundException because my app cannot find the jar file. Naturally, it will work if I put the jar file in WEB-INF/lib, but isn't this redundant, since this jar file is already present in CATALINA_HOME/server/lib? How can I reference this jar from my webapp? Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
server/lib does not become part of the web app classpath. You can put it in common/lib, shared/lib, or your app's WEB-INF/lib.
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I've removed the jar file from server/lib and placed it in common/lib and everything seems to be working fine. Tomcat has not barfed (since it can still find the jar file with its classloader). I don't know why commons-digester.jar was placed in the server-only server/lib directory. Oh well.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps Tomcat itself needs it.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's correct. Tomcat uses digester to make sense out of server.xml
file present in the conf folder.
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but for some reason this jar was placed in the server/lib, where it is visible only to Tomcat. I have several apps which use this jar file, so instead of copying the jar into the respective WEB-INF/lib, I moved it to common/lib, so I don't have to have the jar file all over the place. Tomcat didn't complain, so I think the commons-digester.jar can live in common/lib without a problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic