I am using JSP and EJB's and DAO. In DAO i have used log4j-1.2.8.jar. Initially i deployed and tested with EAR(which includes both JAR and WAR) and was working fine. But when i run the same application after deploying JAR and WAR seperately i am getting java.lang.NoClassDefFoundError: org/apache/log4j/Priority while running my application. This is thrown from the DAO which i used. I checked in the manifest file class path and the jar is fine. Can anybody please guide me why this 3rd party jar is not being picked up.
This is how i am creating the jar
jar cvfm test.jar Manifest.mf META-INF commons-beanutils-1.6.1.jar commons-beanutils.jar commons-collections-2.1.jar commons-collections.jar commons-digester-1.5.jar commons-digester.jar commons-fileupload.jar commons-lang-2.0.jar commons-lang.jar commons-logging-1.0.3.jar commons-logging.jar commons-validator.jar displaytag-1.0-b3.jar jakarta-oro.jar jdom.jar jstl.jar jta.jar log4j-1.2.8.jar menu.jar ojdbc14.jar oscache.jar standard-1.0.4.jar standard.jar struts-1.1.jar Struts-Layout.jar struts-legacy.jar struts-menu-2.1.jar struts.jar velocity-1.4-rc1.jar velocity-tools-view-1.0.jar xerces-2.4.0.jar xmlParserAPIs.jar com
The war should be build as:
classes (your classes expanded)
lib (all 3rd party jars)
Using maven or ant will assist you in building a war in the correct format.
If you are already doing this then try to move the logging jar to the application level classpath.
First try to understand why the java.lang.NoClassDefFoundError error is coming.This error will come when the classA using classB wont find the ClassB at runtime.Everything must have got compiled at the compile time.
The classloader which loads the classA is not able to find the classB. This may happen because.
1. classA is been loaded by enterprise application class loader. and classB is being loaded by webapplication class loader.In this case classA wont be able to locate the classB. So if ur classA is being loaded by application classloader you will have to keep the classB in your enterprise application directory,so that application classloader will load classB and error will go.
2. If classA and classB is present in webapplication and still the error is coming then as previous mail said keep the classB/JAR in WEB-INF\classes or WEB-INF\lib directory.
Hope this solves u r problem