tags:

views:

39

answers:

2

What are the best practices for Spring based application deployment? I have at least two apps based on Spring. I'm deploying them on Tomcat - two instances of the same server with different CATALINA_BASE's.

The result is that size of one of my apps is 30MB and the other is 19MB. Each has same libraries such as Spring, Apache CXF, Hibernate, C3P0 etc.

Is it correct and safe (stable) to keep those libs duplicated in each application and upload 30MB each deploy? Or maybe I should copy common libraries somhere?

+3  A: 

I recommend keepings as they are.

You could put some of the shared libraries into Tomcat's lib directory, but that's just going to make things difficult to upgrade in future, e.g. when you want to upgrade a library, you need to upgrade both apps at the same time.

Tomcat gives each WAR its own classloader, and keeps them isolated from each other. Having the same JAR in two different WARs will not cause a problem.

skaffman
A: 

If you are loading a lot of classes in each war you may run out of PermGen space eventually. If you share the jars through tomcat's lib directory, you may have to load less classes as the common classloader would only load the class once for all apps. If you have the same jar in each app, the classloader associated with each app can potentially load the same classes which can multiply your total number of classes loaded.

However, for the jars you noted, your best bet would probably be to include them in the wars. You will likely want to use different versions of each technology in different wars eventually. PermGen space can always be increased with a java argument if it becomes an issue.

smp7d
I'm planning to restart Tomcat after each depoly to avoid PermGen space problems. Maybe I'll keep JDBC Drivers in Tomcat libs.
peperg