views:

465

answers:

7

I am having four different project, and i am using Weblogic to deploy my projects. There are several libraries ( jar files ) which are common for all projects. Currently each of my project are having lib directory and have almost same set of libraries. Now, is it possible to have this lib directory outside WAR files and access them.

A: 

Well first of all you can put your libs all on the same place and have your build process import the ones needed.

Has for on deploy the new Weblogic 10 has a lib folder in each domain where you can put shared libs. i dont think that is possible before Weblogic 10

Nuno Furtado
There is shared library support in version 9: http://e-docs.bea.com/wls/docs92/programming/libraries.html
McDowell
A: 

I'm currently using another approach.

  1. Create a central repository folder and put all common libraries in there.
  2. In each project you can create a reference to all needed libraries. In Subversion it works with externals

Everytime, the local working copy is updated, the externals are updated to, so you just need to commit to the central folder and it's automatically distributed to all projects.

furtelwart
+5  A: 

Resist the temptation of putting the jar files in the "shared" folder of your container. It is better to keep the jar files where they are now. It may sound a good idea to use a shared folder now, but in the future you may need to deploy an application that requires a shared library, but a different version.

That being said, I have no experience with WebLogic. In Tomcat there is a shared folder with libraries common for all deployed applications. It is not a good idea to use this. If WebLogic can be configured to use a shared folder per a set of applications (and not for all deployed applications) you could go for it.

kgiannakakis
Good advice!There is very little overhead in having an extra copy of a jar file, whereas, having to fudge two versions of a common library from the same location or forcing all your apps to upgrade to a new version at the same moment is a real pain.
James Anderson
Actually after compiling the project size is around 1.5 mb ( without libs ) , and 20 mb ( with libs )
Rakesh Juyal
You may use the shared folder in your development machine in order to make the deployment quicker. In a production environment, this doesn't matter much, so prefer a big WAR file with all jars inside. If you do so, you need to do testing twice (both for small and big WAR).
kgiannakakis
+2  A: 

Do you want to do this ? Unless you're stuck for deployment space, I would (perhaps) advise against it.

Why ? At the moment you have 4 solutions running off these libs. If you have to upgrade one of the libs (say, if you discover a bug, or if you require a new feature), then you're going to have to test compatibility and functionality for all 4 solutions. If each solution has its own set of libs, then they're sandboxed and you don't have to move all 4 in step.

Note that all this hinges on how easy it is to regression-test your solutions. You may find it easy, in which case using the same set of libs is feasible.

Brian Agnew
+1  A: 

Don't do that.

The whole idea of WAR files is that they are self-contained units. This makes deployment so much easier.

In addition to the possible version conflicts that others have pointed out, putting jar files in /shared can have very nested consequences for class visibility. They will be on a separate classloader, and be unable to see the classes in the WAR file. If you use libraries that rely on Class.forName() to work (and there are plenty), this could get very painful.

If you really, really cannot afford the extra disk space and memory look at OSGi or Spring DM. They have solved this problem, but at the price of increased complexity.

Thilo
+1  A: 

Put all the shared jar files under common\lib folder of weblogic. common\lib is accessible by all the deployed apps.

Silent Warrior
A: 

You can put the jars in their own ear file and deploy it as a shared library.

You can also put the wars in an ear and add the shared jars to APP-INF/lib. This is a Weblogic extension of J2EE, so it won't work on other servers.

Jon Strayer