Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error while deploying a standalone application  RSS feed

Nitin Kumar
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!