Search code examples
javajardependenciesclasspathear

Is there a way to add a web-inf/lib classpath to a standalone jar in an ear?


I have a fragile legacy application whose structure I do not want to change. It is bundled as an EAR, with a few WAR applications and some supporting jars.

I am introducing some Load Time Weaving AOP in which one Aspect has a dependency on a jar in the war/WEB-INF/lib folder.

My AOP jar is in my EAR/lib folder.

I don't want to move my webapp's jar to the ear/lib folder as this may cause other side effects with parent-first classloading.

Is there any way to use the Manifest of my AOP jar and point to the lib in the War/WEB-INF folder? Is there a way to write the classpath as something like

Class-Path: webapp.war/WEB-INF/lib/dependency.jar

or

Class-Path: webapp.war:WEB-INF/lib/dependency.jar

Solution

  • No, that's not possible. There might be hacks to work around this, but it generally doesn't look like a good design approach. You could try to extract the aspect which has a dependency on a lib in the war and move it to this war. Or to extract only the required functionality from dependency.jar. Hard to say, without more information.