It's not a secret anymore!
The moose likes Tomcat and the fly likes Error while deploying a standalone application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Error while deploying a standalone application" Watch "Error while deploying a standalone application" New topic

Error while deploying a standalone application

Nitin Kumar

Joined: Apr 18, 2005
Posts: 29
I have two java projects which is the result of separating one big appliaction in two smaller ones. First project is a library project and have common class that is used in different applications and second one is a separate module which depends on first on.I compliled both of them using
Eclipse after proper settings and including jars. Let the projects be ProjA(library) and ProjB (application).
Both of them have common package structure and have two java classes, as metioned below
ProjA : MyPack.BasicApplicationLifecycleListener
ProjB : MyPack.ApplicationLifecycleListener

BasicApplicationLifecycleListener implements ServletContextListener and ApplicationLifecycleListener extends BasicApplicationLifecycleListener as well as implements ServletContextListener.

I moved both of them to standalone tomcat server and am trying to deploy ProjA , but I am getting following error during startup of the server

Error configuring application listener of class MyPack.ApplicationLifecycleListener
java.lang.NoClassDefFoundError: MyPack/BasicApplicationLifecycleListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(

I tried following

1 Moved the BasicApplicationLifecycleListener.class from ProfA/classes/MyPack to ProfB/classes/MyPack , ( which is wrong as it defeats the basic purpose of separating the two applicagtions), but this time it gives another error as fllows

Error configuring application listener of class
java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(
at java.lang.Class.getConstructor0(

The class DocumentException is there in one of the Jars.

2 Set the class path to ProjcA/src and to the Jar which contains DocumentException.class. Still it doesnot work.

Where am I going wrong? Secondly I would like to know that if the two projects compliled successfully, why is it throwing above mentioned error while deploying?
Does the listener classes are complied once again during startup ?

PS: One of colleague who is using a hogher version of Eclipse ( mine is 3.0 coupled with MyEclipse 3.8.4 ) is able to
deploy the two projects using Eclipse.

If the above information is not sufficient then please let me know so that I can provide somre inputs.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Tomcat ignores your classpath.
Its classloaders look for the classes in a series of directories.

Jar files should be placed under tomcat/webapps/{your_web_app}/WEB-INF/lib/
Classes should be placed under tomcat webapps/{your_web_app}/WEB-INF/classes/{your_package}/

You can share classes by placing them under tomcat/shared/lib or tomcat/shared/classes but it's better, in my opinion, to package each web application as a complete app. Most people are using build tools such as ANT to replicate files as needed at build time.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Error while deploying a standalone application
It's not a secret anymore!