views:

588

answers:

3

I m new to Jboss I have multilpe 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 jar to common location so that I dont have to put these in each war file. I guess location is server/default/lib. But i am not sure?

Also how its different that having those jar at location WEB-INF/lib vs. JBOSS/server/default/lib. Will I face any classloader issue?

Also I have static data stored in static fields like Singleton, will those be shared across all WAR files?

Thnks.

A: 

JBOSS/server/default/lib works fine.

All the jars in that folder will be loaded into JBoss.

Gordon
+6  A: 

Classloading:

You're right, put the .jars to JBOSS/server/<configuration>/lib, or JBOSS/lib.

JBoss AS comes with bundled Hibernate libs which are tested with that AS version.

See jboss-6.0.0-SNAPSHOT\server\default\conf\jboss-service.xml:

<server>
  <!-- Load all jars from the JBOSS_HOME/server/<config>/lib directory and
       the shared JBOSS_HOME/common/lib directory. This can be restricted to
       specific jars by specifying them in the archives attribute.
       TODO: Move this configuration elsewhere
  -->
  <classpath codebase="${jboss.server.lib.url}" archives="*"/>
  <classpath codebase="${jboss.common.lib.url}" archives="*"/>
</server>

Also see:

Static data:

Don't rely on static fields. If you want to share data amongst more WARs, use an external storage - a database, a file (with synchronization if you write to it), JBoss Cache, etc.

Ondra Žižka
+1 i prefer a own dedicated directory for my own shared jar's this makes it easier to maintain
stacker