4 Replies Latest reply on Dec 15, 2014 11:50 PM by Jay SenSharma

    Jboss EAP6.2 multiple context-root issue

    Vinoj Mathew Newbie

      Hi All,

       

      I am deploying the application on jboss eap6.2 in standalone mode.

       

      I have one war file with multiple context root which is package in one ear file. For both, the war file is same only the context root is different. I have to access the application  like

      localhost:8080/test

      localhost:8080/test1

       

      When I  deploy the application only the second context root is set, not the first one.In other words only the context root which is mentioned  second will only will takes place. In weblogic we dont have any issue. I am migrating the project from weblogic to jboss eap6.2. Any help is really appreciated

       

      My application.xml file looks like this:

       

      <module>

          <web>

            <web-uri>xxxxx-0.0.1-SNAPSHOT.war</web-uri>

            <context-root>test1</context-root>

          </web>

        </module>

        <module>

          <web>

            <web-uri>xxxxx-0.0.1-SNAPSHOT.war</web-uri>

            <context-root>test</context-root>

          </web>

        </module>

       

      Thanks

        • 1. Re: Jboss EAP6.2 multiple context-root issue
          Jay SenSharma Master

          Adding multiple duplicate module with different context-root  inside application.xml will not help.

           

          Rather you can try adding only one <context-root>test</context-root>  and map test  to test1, test2, test3  using    Rewrite Valve inside the JBoss Web SubSysem as following:

           

                <subsystem xmlns="urn:jboss:domain:web:1.5" 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="^/test1(.*)$" substitution="/test/$1" flags="R"/>
                          <rewrite name="rule-2" pattern="^/test2(.*)$" substitution="/test/$1" flags="R"/>
                          <rewrite name="rule-3" pattern="^/test3(.*)$" substitution="/test/$1" flags="R"/>
                      </virtual-server>
                  </subsystem>
          

           

          Now you should be able to access this application using any of the following URL:

           

          http://localhost:8080/test

          http://localhost:8080/test1

          http://localhost:8080/test2

          http://localhost:8080/test3

          • 2. Re: Jboss EAP6.2 multiple context-root issue
            Vinoj Mathew Newbie

            Thanks Jay let me try and will update.Thanks for the Input

            • 3. Re: Jboss EAP6.2 multiple context-root issue
              Vinoj Mathew Newbie

              Hi Jay,

               

              I just tried to test this. But if i do http://localhost:8080/test1 its redirect to http://localhost:8080/test

               

              I have different config file for different context path. Is there any way I can still retain the same context path

              which mean  when i do http://localhost:8080/test1 it should not redirect to http://localhost:8080/test  ( I mean the context path should be test1)

               

              Thanks for the help

              Vinoj

              • 4. Re: Re: Jboss EAP6.2 multiple context-root issue
                Jay SenSharma Master

                According to EE6 specification:

                 

                EE.8.4.1  "Assembling a Java EE Application"

                Assign a context root for each web module included in the Java EE application. The context root is a relative name in the web namespace for the application. Each web module must be given a distinct and non-overlapping name for its context root. The web modules will be assigned a complete name in the namespace of the web server at deployment time. If there is only one web module in the Java EE application, the context root may be the empty string. If no deployment descriptor is included in the application package, the context root of the web module will be the module name. See the servlet specification for detailed requirements of context root naming.

                 

                 

                As specification states that "Each web module must be given a distinct and non-overlapping name for its context root", So from Specification perspective i do not see an option of having multiple context-root for the same application.

                 

                Is there any specific need you want have multiple context-root for the same web application?

                 

                [1] http://download.oracle.com/otndocs/jcp/javaee-6.0-fr-oth-JSpec/