From: "Tait E Larson" <[EMAIL PROTECTED]> Sent: Wednesday, July 17, 2002 10:56 AM Subject: explicit ordering of jars searched by classloader in web application
> I've got three third party jar files in the WEB-INF/lib directory of my web > aplication that contain different versions of the same classes. I need to > explicitly state the order in which the classloader searches these jars in > order for my web application to work correctly. Can this be done by > manipulating the classloader at runtime? Would it be possible to explicitly > state the jar ordering somewhere in web.xml? Wow! That's certainly a issue that's fraught with peril. Depending on how the container is written, it could be placing the jars in the lib directory in a couple of different orders. They could be in alphabetical order, or they could be in directory order (i.e. the order they show up in an unsorted directory). The Servlet Spec doesn't have anything about ordering the jars in lib directory, so while a container can offer some specific information, it won't be portable to another container. You certainly shouldn't rely on the system directory layout itself, as that could change by simply reloading the directory, or from platform to platform. The BEST solution would be to pull the jars apart and build a single "correct" jar that is not dependent upon the classpath load order. The easiest way to do this would be to simply unjar them in "reverse classpath order", so that whatever you want search first is unjarred last. For example: $ mkdir newjar $ cd newjar $ jar xf /path/to/3rdPartyLibOriginal.jar $ jar xf /path/to/3rdPartyLibServicePack1.jar $ jar xf /path/to/3rdPartyLibServicePack2.jar $ jar cf /path/to/Integrated3rdPartyLib.jar . Basically, this lets the latter jars overwrite the same named classes from the earlier jars, and has the same effect as placing them before one another in a classpath. The other solution is to put them on the system classpath in the order desired, but then they're not in the webapp WAR file. Regards, Will Hartung ([EMAIL PROTECTED]) -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>