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 Error while deploying a standalone application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Error while deploying a standalone application" Watch "Error while deploying a standalone application" New topic
Author

Error while deploying a standalone application

Nitin Kumar
Greenhorn

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(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

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 de.skandia.sm.servlets.ApplicationLifecycleListener
java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)

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.

Thanks
Ben Souther
Sheriff

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: http://aspose.com/file-tools
 
subject: Error while deploying a standalone application