-
1. Re: how to create multiple Context roots without using rewrite in single war file and how to access multiple context roots web-app single war file
andey Mar 31, 2017 7:22 AM (in response to naidukdk)Hi,
No, it is not allowed by Java EE spec.
Take Java EE 6 spec(http://download.oracle.com/otndocs/jcp/javaee-6.0-fr-eval-oth-JSpec/). as example:
Choose unique names for the modules contained in the application. If two
modules specify conflicting names in their deployment descriptors, create
an alternate deployment descriptor for at least one of the modules and
change its name. If two modules in the same directory of the ear file have
the same base name (e.g., foo.jar and foo.war), rename one of the
modules or create an alternate deployment descriptor to specify a unique
name for one of the modules.
Please note: Choose unique names for the modules contained in the application, and specify a unique name for one of the modules
Suppose I have a war deployment test.war, I deploy it with 2 different context-root names (for example, /test1 and /test2) on JBoss Enterprise Application Platform (EAP),
In application.xml:
<module>
<web>
<web-uri>test.war</web-uri>
<context-root>test1</context-root>
</web>
</module>
<module>
<web>
<web-uri>test.war</web-uri>
<context-root>test2</context-root>
</web>
</module>
You can duplicate the war file and deploy both:
test1.war --> http://localhost:8080/test1
test2.war --> http://localhost:8080/test2
context-root name and deployment file name should be unique (one-to-one mapping) as per Java EE spec.