简体   繁体   中英

How to share libs between web applications with JBoss

I have 10 web applications deployed on JBoss. Each one has about 20 jars in web-inf/lib ... most of which are the same in each web application.

It's tedious to add all of these identical libraries to each WAR file. I'd rather just have these libraries shared across all applications. So I'd like to put all of these jar files in one place where all of the web applications can reference them.

Also, I only want 5 of these 10 web applications to reference these shared jar files, I want to pick and choose which applications references these shared libraries.

How could this be accomplished?

我建议使用Maven来管理您的依赖项。

put the jars in [JBOSS SERVER]/lib directory, so the libraries are available for all application under this server. or this thread might solve your issue.

You may drop the common jars into a location and provide the path during runtime

-Djboss.server.lib.url=file://shared/lib/path

For All application where you want jars in webapp/lib to override one in file://shared/lib/path Configure jboss-web.xml

Scoped Class Isolation

<jboss-web>
   <class-loading> 
      <loader-repository>com.example:archive=unique-archive-name</loader-repository> 
   </class-loading>
</jboss-web>

Isolation with Overriding Server Classes

<jboss-web>
   <class-loading java2ClassLoadingCompliance="false">
      <loader-repository>
         com.example:archive=unique-archive-name
         <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
      </loader-repository>
   </class-loading>
 ...

See http://community.jboss.org/wiki/ClassLoadingConfiguration for further details

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