• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
typo, I meant:



instead of - .../Tomcat5/webapps/R/WEB-INF/web.xml
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, on both counts.
 
Let's get him boys! We'll make him read this tiny ad!
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!