JSF .war Example

This example takes a normal JSF build, and wraps it into a -swarm runnable jar.

Please raise any issues found with this example in our JIRA:

Project pom.xml

This project is a traditional JAX-RS project, with maven packaging of war in the pom.xml


The project adds a <plugin> to configure wildfly-swarm-plugin to create the runnable .jar.


To define the needed parts of WildFly Swarm, a dependency is added


These dependency provides the JSF and CDI APIs to your application, so the project does not need to specify those.


  • mvn package && java -jar ./target/example-jsf-war-swarm.jar
  • mvn wildfly-swarm:run
  • From your IDE, run class org.wildfly.swarm.Swarm


Since WildFly Swarm apps tend to support one deployment per executable, it automatically adds a jboss-web.xml to the deployment if it doesn't already exist. This is used to bind the deployment to the root of the web-server, instead of using the .war's own name as the application context.

$ curl localhost:8080/index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns=""><head id="j_idt2">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>WildFly Swarm Facelet</title></head><body>

    <div id="top"><h1>WildFly Swarm Facelet</h1>

    <div id="content">Hello from JSF

    <div id="bottom">Powered by WildFly Swarm


or access http://localhost:8080/ in your browser.