0

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?

JasonStoltz
  • 3,040
  • 4
  • 27
  • 37
  • Duplicate of [Where to put a shared library in JBoss AS 5?](http://stackoverflow.com/q/2108975/127035)? – ewan.chalmers Nov 17 '11 at 15:16
  • Hmm... not sure that answers the last part of my question though. Can i pick and choose which apps use libs in that directory? – JasonStoltz Nov 17 '11 at 15:18
  • I think my question might actually duplicate this question: http://stackoverflow.com/questions/3305661/jboss-custom-lib-directory, though, the answers there don't seem great. – JasonStoltz Nov 17 '11 at 15:28

3 Answers3

1

I recommend to use Maven to manage your dependencies.

Puce
  • 37,247
  • 13
  • 80
  • 152
  • You know what, I was literally just thinking that and was actually going to edit this post with that question. I could probably just have a common set of jar file in like a parent POM file or something that all of these different projects could inherit from. – JasonStoltz Nov 17 '11 at 15:45
  • Yes, either declare them in a parent POM or group them in a "dependency" POM as described here: http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-best-practice.html – Puce Nov 17 '11 at 15:59
  • Accepting this answer. I was ultimately looking for a way to avoid manually copying those jar files into each WAR and managing them individually ... by using a dependency management tool like Maven I am able to centrally manage the common dependency across all the applications. – JasonStoltz Nov 21 '11 at 12:44
0

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.

Community
  • 1
  • 1
Muhammad Saifuddin
  • 1,284
  • 11
  • 29
  • 1
    I'm not quite sure if that's the complete answer ;-) He wrote **only 5 of 10 apps** should reference it, if he follows this, **all** apps will ... or at least could ... – gilaras Nov 17 '11 at 15:21
0

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

Prashant Bhate
  • 10,907
  • 7
  • 47
  • 82