tags:

views:

62

answers:

3

I am working with a team of programmers developing web applications for a J2EE Application Server (currently using JBoss but switching to GlassFish in the near future). We were wondering whether we should install the libraries used by our applications on the J2EE server itself or package these libraries with every .war file that we deploy to the server.

The obvious advantage of installing the libraries on the server in a common location is much lighter-weight application packages, but on the other hand we want to ensure that we won't run into problems down the line when we want to use newer versions of these installed libraries.

I realize this question really doesn't have an answer per se but I feel as if there is definitely a right or wrong way to go about doing this.

+3  A: 

In general, keep your application specific libraries in your EAR/WAR. As you find yourself deploying more libraries and applications, you'll find one somewhere that causes a compatibility problem with another application. (Even commons-logging causes me issues with this.)

I think Application Servers should be as lean and mean as possible, and keep the classpath unpolluted. Keep your libs in your EARS.

Chris Kaminski
+1, We package our libraries with our WAR/EAR for precisely this reason.
R. Bemrose
That makes a lot of sense, thanks for the input!
TimmyJ
+1  A: 

To play devil's advocate to darthcoder, packaging it with your ear is definitely better for deployment, but you will lose time every time you rebuild and deploy the ear/war. Depending on how many jars, this will add up over time so for development it might be better to put them in your container. (Especially with the PermGen redeploy issues...) I do agree that for production they should be bundled with your application.

PHeath
+1 Good point.
Chris Kaminski
A: 

Always package all the jars you need in the EAR/WAR. Don't worry about size and build time - I've worked with EAR's that are 30 Megs and 70 Megs and wasn't a major problem - also means deploying to a new application server is easy. You'll always deploy from the box where the application server is (ftp/copy EAR/WAR there first).

If you used some funky tool then you could probably significantly cut down the size of your EAR/WAR by only including what is absolutely necessary.

In my experience, the less you depend on the application server being properly configured, the better.

Michael Wiles