Replace JBoss homepage with application home page

Viewed 182

I have web application which is being deployed on JBoss Server. When accessing the url, i am seeing Jboss welcome page Snip of page i am seeing

Now i have to add WAR name /test to access the home page of url. But i want to access homepage without appending /test to url.

I have web.xml and jboss-deployment-structure.xml.

I tried to add jboss-web.xml to the solution but that cause deployment to fail.

I also tried naming war to ROOT but that also caused deployment to fail.

I am using openshift for creating build and deploying application

Snip of web.xml

<display-name>aad</display-name>     

<servlet>
    <servlet-name>test</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
         <param-value>/WEB-INF/classes/aad-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>test</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

SNIP of jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
    <exclude-subsystems>
        <subsystem name="jpa" />
    </exclude-subsystems>
   <!--  <exclusions>
        WFCORE-209 workaround
        <module name="javaee.api" /> 
        <module name="javax.persistence.api" />
        <module name="org.hibernate" />
    </exclusions> -->
    <dependencies>
        <!-- WFCORE-209 workaround -->
        <module name="javax.activation.api" export="true"/>
        <module name="javax.annotation.api" export="true"/>
        <module name="javax.ejb.api" export="true"/>
        <module name="javax.el.api" export="true"/>
        <module name="javax.enterprise.api" export="true"/>
        <!-- <module name="javax.enterprise.deploy.api" export="true"/> -->
        <module name="javax.inject.api" export="true"/>
        <module name="javax.interceptor.api" export="true"/>
        <module name="javax.jms.api" export="true"/>
        <module name="javax.jws.api" export="true"/>
        <module name="javax.mail.api" export="true"/>
        <module name="javax.management.j2ee.api" export="true"/>
        <!-- <module name="javax.persistence.api" export="true"/> -->
        <module name="javax.resource.api" export="true"/>
        <module name="javax.rmi.api" export="true"/>
        <module name="javax.security.auth.message.api" export="true"/>
        <module name="javax.security.jacc.api" export="true"/>
        <module name="javax.servlet.api" export="true"/>
        <module name="javax.servlet.jsp.api" export="true"/>
        <module name="javax.transaction.api" export="true"/>
        <module name="javax.validation.api" export="true"/>
        <module name="javax.ws.rs.api" export="true"  services="export"/>
        <module name="javax.xml.bind.api" export="true"/>
       <!--  <module name="javax.xml.registry.api" export="true"/> -->
        <module name="javax.xml.soap.api" export="true"/>
        <module name="javax.xml.ws.api" export="true"/>

        <!-- This one always goes last. -->
        <module name="javax.api" export="true"/> 
    </dependencies>
</deployment>
1 Answers

To deploy an application under the root context path, you should set the context path to an empty path. By default, the context path is the application name. One way to specify the context path explicitly, is by including a WEB-INF/jboss-web.xml file:

<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
      http://www.jboss.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
    <context-root>/</context-root>
</jboss-web>

Also, you need to ensure that no existing application is deployed under the root context path. To do so, remove the welcome-content handler from your jboss configuration. For example in standalone.xml remove <location name="/" handler="welcome-content"/> from:

            <server name="default-server">
                <http-listener name="default" socket-binding="http" redirect-so$
                <https-listener name="https" socket-binding="https" security-re$
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content"/>
                    <http-invoker security-realm="ApplicationRealm"/>
                </host>
            </server>
Related