hetaoblog
hetaoblog

Reputation: 2030

is there a way to combine different java web application to one web application (war) without impacting each other?

I'm running an application with several different features, they are completely independent; the only reason is i run them together is i run them on a small vps with limited memory;

I'm expecting:

  1. develop each module seperately

  2. combine them together into one application using some ant tasks;

for a ear file, we can combine several different war files into one, and they can run fine without impacting each other, however, since I'm running a tomcat and do not want to involve heavy containers like jboss or so on, an ear file is not available;

is there a way that we can achieve this? such as we develop something standalone and then package them into a jar, put it into web-inf/lib and it will just work? thx.

the options i've used:

  1. develop them in one application, using different dir to seperate them
  2. develop them in many different applications and deploy them as different web applications in tomcat, but this one seems to load duplicate classes under web-inf/lib into memory, which is not a good option, while i do not like to putting them all to tomcat/lib...

Upvotes: 1

Views: 1940

Answers (2)

You need to build some kind of wall, so would exist a technical restriction to avoid that a bad developer could break your design generating innecesary dependence. You could put all the java classes in different jars embedded in your new merged web project and just keeping the web content in the same project but separate folders.

Maven+SVN could host and provide the jars to the new project.

Upvotes: 0

aroth
aroth

Reputation: 54856

You can do this using Maven (if you're happy to use Maven instead of Ant), and the Cargo plugin for Maven. It has an 'uberwar' packaging format that allows multiple WAR files to be merged into a single combined WAR file. Details are available here:

http://cargo.codehaus.org/Merging+WAR+files

Upvotes: 4

Related Questions