VOOZH about

URL: https://www.javacodegeeks.com/2017/05/configuring-multiple-context-root-single-webapp-jboss.html

⇱ Configuring multiple context root for a single webapp – JBoss - Java Code Geeks


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:

webapp/WEB-INF/jboss-web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
 <context-root>appA</context-root>
 <session-config>
 <session-timeout>10</session-timeout>
 </session-config>
</jboss-web>

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

jboss-eap/standalone/configuration/standalone.xml:

<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="example.com"/>
 <rewrite name="rule-1" pattern="^/appB(.*)$" substitution="/appA$1" flags="L"/>
 <rewrite name="rule-2" pattern="^/appC(.*)$" substitution="/appA$1" flags="L"/>
 </virtual-server>
</subsystem>

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 “/”.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Thank you!

We will contact you soon.

Tags
JBoss
👁 Photo of Arpit Aggarwal
Arpit Aggarwal
May 11th, 2017Last Updated: May 11th, 2017
0 1,017 1 minute read

Arpit Aggarwal

Arpit is a Consultant at Xebia India. He has been designing and building J2EE applications since more than 6 years. He is fond of Object Oriented and lover of Functional programming. You can read more of his writings at aggarwalarpit.wordpress.com
Subscribe

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button
Close
wpDiscuz