Hi, I am deploying an EAR containing my EJB Jars and a webapp WAR file. I have been using the manifest file from each of the EJB JAR files to sort out any dependancies with no trouble. The problem that i am now having is that third party jars required by the webapp are not being picked up from the WEB-INF/lib directory inside the WAR file as expected? The WAR works fine under Tomcat. Has anybody else found this? Its very strange as it is very simple and isn't working. Thanks
I have solved this problem after a lot of head scratching. J2EE apps have 2 class loaders one for the EJB's and the second for the Webapps. The Webapp class loader is a subclass of the EJB Classloader. I had all of my source in a jar file at the root level of the EAR file so that the EJB's could find any dependencies (Value objects etc) via the Class-Path: Manifest element. As the EJB class loader is invoked first it was loading my class that accesses the third party jar (stored in the WAR's WEB-INF/lib). When the Webapp classloader gets its turn it does not load any classes that have already been loaded (why should it bother). Because of this when the classs that attempts to access the third party jar is accessed it is the version inside the classes.jar at the root of the EAR that is executed and yes you have guessed it, it cannot find the third party jar as it is inside the WAR which it cannot access! The solution was therefore make sure there were no duplicate classes in the EAR and WAR (i the WEB app or EAR only contains necessary files) A tricky one! Dan
Hi Dan, Just to clarify things, you have your presentation logic in the WAR and business logic in the EAR jars. So if I had a value object that was needed in the presentation layer, would I have to include this in the WAR as well as the EAR so that it was properly loaded by both classloaders? Thanks in advance.
Sun Certified Java Developer <br />Sun Web Component Java Developer<br />Sun Certified Java Programmer