简体   繁体   中英

How to refer a jar file of a particular .war in other .war file

I have many jar files in WEB-INF/lib folder of my web application, Now my requirement is, III have to package few of these jar files as new.war file.

Now I have to refer these isolated jar files of new.war in my first web application.

Note : We are using weblogic server to deploy these .war files

Please let me know the steps to follow to refer the jar files of a .war from other web application.

A direct reference is not possible, AFAIK. You can do two things:

  1. Package both WARs in one EAR, then put the shared JAR files in APP-INF/lib on EAR level

  2. Put the JARs in an "Optional Package", then deploy that and reference the Optional package from the MANIFESTS of the WARs.

You are very near to class loader hell here, though. Prepare for surprises with object identity around equality (same data but still not equal since loaded from different classloaders), "singleton fun" (multiple instances since each WAR has the Optional Package in its own classloader) and (de-) serialization issues (ClassNotFound).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM