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 can't find classes in /WEB-INF/classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "TOMCAT can Watch "TOMCAT can New topic
Author

TOMCAT can't find classes in /WEB-INF/classes

Nina Anderson
Ranch Hand

Joined: Jul 18, 2006
Posts: 148
Hi Guys,

My web application is throwing a ClassNotFoundException when I try to startup Tomcat. However, the class does exist in the my application's /WEB-INF/classes. How can I get Tomcat 5 classloader to find my class files? I'm new to using Tomcat and I dont know how it thinks.

Here's my code:

#### web.xml ######



########## File Structure ########################

+ tomcat5
+ webapps
+ MYWebApp
+ WEB-INF
+ classes
+ com.myWebApp.common.LoadAllAppDropDownList
+ lib

+ ROOT
+ WEB-INF
+ web.xml {the one I'm using}
+ server
+ shared
+ common


########## ERROR ########################

Here's the error I'm getting:
2008-09-16 06:11:17 StandardContext[]Error configuring application listener of class com.myWebApp.common.LoadAllAppDropDownList
java.lang.ClassNotFoundException: com.myWebApp.common.LoadAllAppDropDownList
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3779)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4323)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:701)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)


Thanks ....in Advance!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
ROOT and MYWebApp are completely separate web apps. What you have in the web.xml file of one has no impact on the other. It sounds like you need to copy the web.xml you're working on to the MYWebApp/WEB-INF directory, and take it from there.


Ping & DNS - updated with new look and Ping home screen widget
Ravindra Verma
Greenhorn

Joined: Sep 16, 2008
Posts: 8
Hi,
This seems to be a configuration problem. Try putting the directory(WEB-INF/classes) in the classpath environment variable before accessing them. Otherwise tomcat can not find these classes.
Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Try putting the directory(WEB-INF/classes) in the classpath environment variable before accessing them. Otherwise tomcat can not find these classes.

Tomcat does not use the CLASSPATH variable, so this won't help.
Nina Anderson
Ranch Hand

Joined: Jul 18, 2006
Posts: 148
Hey guys,

Thanks for you suggestions. But...I'm still confuse. Here are my questions:

1) In order for my web application to come up...which web.xml does Tomcat read?


2) When I deploy my MYWebApp.war file, I place it under



Is this the right location?

3) After deploying the following directory structure is available on the server


Are you guys saying Tomcat is reading this web.xml on startup?

4) Currently, I have copied contains of my web.xml in Step#3 to


Is this wrong?

please HeLP cuz I'm clueless where Tomcat is readying the files.
Nina Anderson
Ranch Hand

Joined: Jul 18, 2006
Posts: 148
typo, I meant:



instead of - .../Tomcat5/webapps/R/WEB-INF/web.xml
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
This is the web.xml that's relevant for your web app, and where you need to configure the listener you were having trouble with:
.../Tomcat5/webapps/MYWebApp/WEB-INF/web.xml


This file is not related to your web app, so you should not put anything into it that relates to MYWebApp:
- .../Tomcat5/webapps/Root/WEB-INF/web.xml
Nina Anderson
Ranch Hand

Joined: Jul 18, 2006
Posts: 148
thanks Ulf,

So, you are saying I should:

1) keep the default web.xml that came with the Tomcat5 installation in
../Tomcat5/webapps/Root/WEB-INF/web.xml?

2) Leave my web application's web.xml (containing String & Struts config) in ../Tomcat5/webapps/MYWebApp/WEB-INF/web.xml?

ThaNKs
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Yes, on both counts.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TOMCAT can't find classes in /WEB-INF/classes
 
Similar Threads
ListenerStart Error
Deploy Spring Application to tomcat
Head First page 740 getting error in log file
JSF 1.1 and Tomcat 6
Exception sending context initialized event to listener instance of class com.sun.faces.config.Confi