rlegendi
rlegendi

Reputation: 10606

Is it possible to deploy multiple war files under the same deployment path?

Let's say I have:

Is it possible that I deploy them both somehow to the same deployment path? E.g., to access it at:

Are the content of the war files merged somehow? How are file conflicts handled (e.g., let's say both of them has an index.jsp file)?

Thx in advnace!

Upvotes: 1

Views: 1662

Answers (2)

VGR
VGR

Reputation: 44293

The servlet specification explicitly forbids this. Deployed web applications may not have identical or overlapping context roots. From the Servlet 3.0 specification, section 10.5:

Since the context path of an application determines the URL namespace of the contents of the Web application, Web containers must reject Web applications defining a context path that could cause potential conflicts in this URL namespace. This may occur, for example, by attempting to deploy a second Web application with the same context path.

Upvotes: 3

Drew Wills
Drew Wills

Reputation: 8446

Yes & no.

I don't think it's possible to somehow merge them into the same file system path within a servlet container like Tomcat (unless you were to write some kind of complicated, intelligent script to do so). For starters, each .war will have a WEB-INF/web.xml file, and each will rely on the contents of its own file to function -- which would win?

But you conceivably could...

  • Deploy to 2 different contexts (or containers, or hosts), and employ some kind of load balancer (hardware or software) to route some requests to one, other requests to the other.
  • Use an "overlay" strategy (such as Maven Overlays) to make a second (and final) .war that is a derivative and extension of another .war file

Upvotes: 2

Related Questions