Reputation: 743
I'd like to deploy multiple versions of a .war
on the same Tomcat, on different paths. For example, I'd like old.war
to serve requests on /
, and then new.war
to serve requests under /new/
.
The war
s will contain different versions of the same code, so mostly the same packages/classes. This also means they will serve the same endpoints, but naturally with different prefixes (eg, when a request comes for /someendpoint
, it should be served by old.war
, and when another comes for /new/someendpoint
, it should be served by new.war
).
Upvotes: 1
Views: 1943
Reputation: 5085
Yes its definitely possible. The only thing to take care about is that no two names of war should be equal.
A good strategy would be use a naming convention to your war. Say eg: project_0_0_1.war and the next one as project_0_0_2.war and so on. You would be then able to deploy different version and yet use all of them
Upvotes: 1
Reputation: 1434
The simple answer is yes. Name them ROOT.war and new.war.
It gets complicated when using ROOT.war since all url references contain empty context
someserver/someendpoint
but new.war will have "new" in all of the paths
someserver/new/someendpoint
My approach was to always use relative url references with the application or to set a application scoped variable with the server for context name and then use
servletContext.setAttribute("cp", contextPath);
${cp}/someendpoint in generated urls.
It is easier if you don't use ROOT.war but instead use old.war and new.war.
Upvotes: 3