File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat's default classpath?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Watch "Tomcat New topic
Author

Tomcat's default classpath??

Darren Hall
Greenhorn

Joined: Jan 22, 2006
Posts: 12
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
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@1c92535
com.abc.framework.controller.ControlServlet
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???

Thanks,

Darren
[ July 24, 2006: Message edited by: Darren Hall ]
Darren Hall
Greenhorn

Joined: Jan 22, 2006
Posts: 12
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.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat's default classpath??
 
Similar Threads
jar in WEB_INF lib not loaded
Marking servlet HelloWorld as unavailable
ServletException please help!!
ZipException: Access is Denied
the requested resource is not available