Oliver
Oliver

Reputation: 3682

Project structure organization: how to make it better?

All -

we have several web applications, all based on some version of Spring developed over time by different team across organizations. They each produce their own WAR, have a different context to work within, and often gets deployed on the same machine, as their functionalities are closely knit together. So we end up with:

tomcat/webapps/{A, B, C ... }

upon deployment, each use a very similar set of tool chains, replicate all Spring jars and dependencies all around.

I am wondering if there is a way to make the project structure better, deploy as a SINGLE war, while allowing each webapp live in their own source repo and have its own pace of development??

Any pointer or references are much appreciated.

Oliver

Upvotes: 1

Views: 301

Answers (4)

jonathan.cone
jonathan.cone

Reputation: 6706

Based on one of your comments to another response, it sounds like you might be more interested in maven's multi-module project feature. This will allow you to define a parent POM with consistent dependencies and project layouts managed across multiple projects.

You might benefit from combining each project into a single WAR, but I do think this is really one of those 'the grass is always greener' problems. One key thing I would keep in mind is figuring out how much longer (or shorter!) is redeployment going to take if the projects were combined.

Upvotes: 1

Ryan Stewart
Ryan Stewart

Reputation: 128829

Think about OSGi. You can deploy all the dependencies just once, build your separate but interrelated modules as OSGi bundles, and deploy and upgrade them all independently. You can also choose whether to deploy them all as WARs (web bundles) or to deploy them as JARs with one or many WARs importing them to tie everything up. Virgo Web Server, formerly Spring DM Server, is really nice and comes ready to do this kind of stuff right out of the box.

Upvotes: 0

Arash Sharif
Arash Sharif

Reputation: 592

you would have to probably move to an app server like jboss, but couldn't you use an ear file and have maven build the modules for you? That way you could probably put them in separate repos if you want each with it's own pom and then have another project with a pom for the ear file:

here is the maven ear plugin:

http://maven.apache.org/plugins/maven-ear-plugin/

here is an older blog post about multiple spring app ear file (single applicationContext fo all wars to share if you need):

http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/

Upvotes: 1

duffymo
duffymo

Reputation: 308763

Deploying in a single WAR will couple all the projects together. Modifying one will mean redeploying all, with the accompanying QA effort to validate and do regression. I wouldn't recommend that.

Multiple copies of Spring JARs can be addressed by putting them in the Tomcat /lib; they're loaded by the Tomcat class loader instead of the WAR class loader. That will mean that every app has to be on the same version of Spring; upgrading one means upgrading all. You'll have to regression test all at once.

What harm is separate WAR files doing you? What do you care if the Tomcat /webapps directory has lots of deployments? One advantage is that they CAN be on separate release schedules. That's a big one to give away. Be sure you have a good reason before doing it.

Upvotes: 3

Related Questions