Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put a shared library in JBoss AS 7

I have multiple web applications each using spring-hibernate and other open source libraries and portlets, so basically now each war file includes those jar files. How do I move these jars to a common location so that I don't have to put these in each war file? My jars are places in D:/ directory.

I tried creating modules but no success. e.g. if I added jar

<resources>
    <resource-root path="mylib.jar"/>
</resources>

and mylib.jar needs another ABC class. That ABC class is in my WAR class-path. Here I get exception while loading this module. mylib.jar could not find ABC class and throws exception.

like image 568
Muhammad Imran Tariq Avatar asked Oct 29 '25 04:10

Muhammad Imran Tariq


1 Answers

If those libraries are reused in several applications, probably the best solution would be to create JBoss modules.

For example, OJDBC library is used in several projects I'm developing. So, I added a new module to JBoss 7: https://community.jboss.org/wiki/CreateAModuleForOracleDatasourceInJBoss711Final (it's just an example).

But you said, that you tried creating modules, but with no luck. What was the problem? Did you get some errors?

EDIT Answer updated in connection with updated question.

So, if I understood correctly, we can divide your libraries into two categories:

  1. First category is "standard libraries": Spring, Hibernate, Log4j etc. So, these libraries might be added as modules into JBoss AS and reused in every WAR (scope=provided in Maven's dependency).
  2. Any other non-standard libraries (i.e. written by yourself) might be added as modules as well. If these libraries require some other dependencies - these dependencies must be listed in module's XML file, as described in: https://docs.jboss.org/author/display/MODULES/Module+descriptors

Hope this helps at least a bit :)

like image 64
Ernestas Kardzys Avatar answered Oct 30 '25 17:10

Ernestas Kardzys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!