How to set the Web Context Path in WildFly

This short article will teach you how to change the Web Context Path for applications running on WildFly or JBoss EAP application server

Context Path defaults

Firstly, by default, a Web application inherits the Web Context Path from its name. Therefore, a Web application whose name is helloworld.war, will be available under the http://localhost:8080/helloworld Context Path

If you are using Maven to build your project, the final application name is determined by the artifactid. However, you can override it through the finalName element of the build section:

      <!-- -->

Choosing a different Context Name

The recommended option to set a non-default Context name for a Web application is to add the jboss-web.xml in the WEB-INF folder of your Web application:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns=""

There, you can choose the Web application context through the context-root element as you can see from the above example.

If you are packaging your Web application in an EAR file, another option is to use the context-root element from the application.xml file:

<application xmlns="" version="1.4"
    xsi:schemaLocation=" /xml/ns/j2ee 



Changing the Web Context of a deployed Web application

Finally, it’s possible to change the Web context of a Web application by using a CLI hack. Follow these steps:

  1. Create a file jboss-web.xml with the Web Context. In our example, we will place it in the /tmp folder
  2. Connect to the CLI (

Once connected, apply the new Web Context using the Deployments Overlay feature:

deployment-overlay add --name=myOverlay --content=/WEB-INF/jboss-web.xml=/tmp/jboss-web.xml --deployments=helloworld.war --redeploy-affected

In this example, the affected deployment is helloworld.war. You can apply the change to multiple applications, even using a regular expression such as “*”. See this example:

deployment-overlay add --name=myOverlay --content=/WEB-INF/jboss-web.xml=/tmp/jboss-web.xml --deployments=helloworld.war,*-admin.war --redeploy-affected

To learn more about deployments overlay, check this article: How to add a web fragment to all applications deployed on WildFly

Finally, if you want to set as Web Context the Root Web Context (“/”) check this tutorial: How to deploy a Web application on the Root Context on WildFly?