• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Tomcat's default classpath??

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I have an application (named 'abc' application) deployed in Tomcat 5.5 on Solaris using the war deploy feature in the manager.

The application (lets call it 'foo') shows up in the manager as '/foo', so I know that it deploys. When I look in catalina.log, I see a ClassNotFound exception, alerting me that the ClassLoader wasn't able to find my ControllerServlet class. Here is the error from Catalina.log:

2006-07-24 09:38:46,987 DEBUG org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Sending application start events
2006-07-24 09:38:46,987 DEBUG org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Starting filters
2006-07-24 09:38:47,002 INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Marking servlet controller as unavailable
2006-07-24 09:38:47,002 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Error loading WebappClassLoader
delegate: false
----------> Parent Classloader:
java.lang.ClassNotFoundException: com.abc.framework.controller.ControlServlet

My ControlServlet class is located in this jar file webapps/foo/WEB-INF/lib/abc.jar in the package com.abc.framework.controller;.

I wanted to confirm that jar files in the WEB-INF/lib directory were included in the classpath for my application. In reading through the online documentation for Tomcat I found the following:

"WebappX - A class loader is created for each web application that is deployed in a single Tomcat 5 instance. All unpacked classes and resources in the /WEB-INF/classes directory of your web application archive, plus classes and resources in JAR files under the /WEB-INF/lib directory of your web application archive, are made visible to the containing web application, but to no others."

I am doing exactly this. My jar file (foo.jar) is in the webapps/abc/WEB-INF/lib directory for my 'abc' application. However, in the Catalina log file, when Tomcat starts, I get the above "ClassNotFound - com.abc.framework.ControlServlet" error. Why can my servlet not be found if it resides in abc.jar under the WEB-INF/lib directory???


[ July 24, 2006: Message edited by: Darren Hall ]
Darren Hall
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, I found the cause of the problem.

Essentially, my build.xml file was not including my compiled classes in the jar file, so the jar was essentially empty and the resulting war file I was deploying contained an empty jar.

Thus the class loader was unable to find my servlet.

I've repaired my build.xml and fixed the issue.

Paper beats rock. Scissors beats tiny ad.
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!