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 / EAP 6 Users

At first you need to set in your standalone/domain configuration file the enable-welcome-root parameter to false (by default it's true) for the web subsystem. The enable-welcome-root controls whether or not to deploy JBoss' welcome-content application at root context.

<subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host">
    <connector name="http" protocol="HTTP/1.1" socket-binding="http" scheme="http"/>
    <virtual-server name="default-host" enable-welcome-root="false">

</subsystem>

Next, you need telling to the Web server to deploy your application on the Root context. For Web applications the standard Web context can be overriden using the jboss-web.xml file descriptor:

<?xml version="1.0" encoding="UTF-8"?>
<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>

If you are using an Enterprise Application Archive then you can set the Web application context in your application.xml using the <context-root>element of the <web> module as follows:

<application version="5" xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
      http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/application_5.xsd">
   <module>
      <ejb>sample-ejb.jar</ejb>
   </module>
   <module>
      <web>
         <web-uri>sample-webapp.war</web-uri>
         <context-root>/</context-root>
      </web>
   </module>
</application>

 

0
0
0
s2smodern

Related articles available on mastertheboss.com

How do I reload dynamically my jsp from an ear ?

  Deploy your Jsp as part of an application deployed in exploded

Where is my compiled JSP ?

JBoss recipe of the day

How do you configure WildFly / JBoss to enable HTTP logging ?

WildFly users WildFly uses Undertow as Web server, which has dep

JBoss Struts tutorial

This article explains how you can setup quickly an application ba

How to restrict access to JBoss web application by IP or Host?

You can create easily Access control list based on the IP address

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

WildFly users For WildFly users you have to include in jboss-web