Configuring multiple context root for a single webapp – JBoss

Sometime back we made changes to our application to support multiple context root leveraging JBoss capabilities by defining one in jboss-web.xml, as follows:


<?xml version="1.0" encoding="UTF-8"?>

And defining the rewrite rule in virtual-server of one of the subsystem in standalone.xml to support other(s) context root, as follows:


<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <virtual-server name="default-host" enable-welcome-root="true">
      <alias name="localhost"/>
      <alias name=""/>
      <rewrite name="rule-1" pattern="^/appB(.*)$" substitution="/appA$1" flags="L"/>
      <rewrite name="rule-2" pattern="^/appC(.*)$" substitution="/appA$1" flags="L"/>

We were happy to go with the above configuration changes then today while promoting the same configuration to production servers, team came back to us that due to some security policies they cannot enable welcome root to “true” in production and if we make it to “false” multiple context are no more supported.

Then we started looking for different configuration options available for virtual-server to resolve the issue and found we have to configure JBoss with the “/” context to support other context(s) and as our application is having context as “/appA” there is no “/” context available and it’s failing in rewriting the context.

Then we have two immediate fix – first is to redefine our application context to “/” which requires a .war file change and second is to drop another application in JBoss deployment which is having context root as “/” and at point of time when team is in the middle of production deployment we cannot make change in .war file so we chosen the second option over first by deploying another webapp with context-root as “/”.



One thought on “Configuring multiple context root for a single webapp – JBoss

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s