JSF - PrimeFaces Hello World Example using WildFly and Maven

PrimeFaces is an open source component library for JavaServer Faces (JSF). It provides a collection of mostly visual components (widgets) that can be used by JSF programmers to build the UI for a web application. An overview of these widgets can be found at the PrimeFaces showcase.

WildFly, formerly known as JBoss AS, is an application server written in Java developed by JBoss. It implements the Java Platform, Enterprise Edition (Java EE) specification. WildFly runs on multiple platforms and is free and open-source software.

The following post illustrates a basic example in which we will configure, build and run a Hello World PrimeFaces example using WildFly and Maven.

Tools used:

JSF 2.2

PrimeFaces 5.3

WildFly 9

Maven 3.5

The code is built and run using Maven. Specified below is the Maven POM file which contains the needed dependencies for JSF and PrimeFaces.

In order to run the Hello World PrimeFaces application, a servlet container is needed and in this example, the WildFly implementation will be used. The deployment of the code and application server will be fully automated using the wildfly-maven-plugin. The plugin has been configured so that the HTTP listener port is set to “9090”.

The context path of our deployed application will be changed to '/codenotfound'. In order to achieve this on WildFly we need to add a jboss-web.xml file in the /WEB-INF directory with a '<context-root>' parameter as explained in this Stack Overflow post.

In order to run the above example open a command prompt and execute following Maven command:

mvn wildfly:run

Maven will download the needed dependencies, compile the code, and start a WildFly instance on which the web application will be deployed. The result should be the following WildFly startup trace which mentions: Deployed "jsf-primefaces-wildfly-0.0.1-SNAPSHOT.war without reporting any errors.