Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Map several context roots to one web-uri in application.xml

I hava such application.xml.

  <module>
    <web>
      <web-uri>services-inboxService.war</web-uri>
      <context-root>/services/inboxService</context-root>
    </web>
  </module>

I would like to map different context-roots to one web-uri. But there are constraints and each module should contain only one web section and each web - only one context-root section. Is there any way except copying this war file named differently?

like image 656
Yegoshin Maxim Avatar asked Aug 16 '12 10:08

Yegoshin Maxim


1 Answers

Yegoshin Maxim- I believe you must be clear about the URI concept in a Java EE based Web application:

<hostname:port/context-root/resource-path?parameters>

Now if someone wants to use a different hostname+port combination to be served by the same installed application, they should use the concept of virtual hosting which is supported by mostly app servers like Tomcat, WebSphere.

If someone wants to use a different resource-path to map to the same resource in a web application, it is done by configuring a url-pattern in web.xml

Now if someone wants to use a different context-root for a single installation of an application, it is not possible. Even if you think from the classloader point of view. A context leads to the creation of a context classloader which is the child of the app server classloader. We can't have more than one context classloader for one web app, otherwise it is impossible to resolve resource/class references. So the only solution is to have multiple instance of an app running under different context roots.

like image 64
ag112 Avatar answered Sep 28 '22 04:09

ag112