How do you configure a Web Application as Default Web app ?

WildFly users

For WildFly users you have to include in jboss-web.xml the Root Web context (“/”) at first:

<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>

Then in your undertow configuration specify which application is deployed on the Root context by setting the default-web-module attribute as in this example:

/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-web-module, value=demoroot.war)

This will result in:

<host name="default-host" alias="localhost" default-web-module="demoroot.war">
    <location name="/" handler="welcome-content"/>
    <filter-ref name="server-header"/>
    <filter-ref name="x-powered-by-header"/>
</host>

You can also specify as default web module a Web application that is packaged as module in an EAR file:

<host name="default-host" alias="localhost" default-web-module="App.ear.demoroot.war">
    <location name="/" handler="welcome-content"/>
    <filter-ref name="server-header"/>
    <filter-ref name="x-powered-by-header"/>
</host>

JBoss AS 7

Follow these steps:

1) Disable the Welcome application by running the following command from JBoss CLI:

/subsystem=web/virtual-server=default-host:write-attribute(name=enable-welcome-root,value=false)

2) Configure your Web application to use the root context.
To configure your web application to use the root context (/) as its URL address, modify its jboss-web.xml, which is located in the META-INF/ or WEB-INF/ directory. Replace its <context-root> directive with one that looks like the following.

<jboss-web>
   <context-root>/</context-root>
</jboss-web>

Deploy your application to the server group or server you modified in the first step. The application is now available on http://SERVER_URL:PORT/.

JBoss AS 4-5-6

  • First you have to remove the default Web application that ships with JBoss (ROOT.war).

  • Then deploy your web application taking care to add in your application the file WEB-INF\jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
   <context-root>/</context-root>
</jboss-web>