WildFly Hello World

In this tutorial we will learn how to create a simple Hello World JAX-RS application for WildFly using the built-in RESTEasy API.

Pre-requisites: You need a WildFly application server. Read here how to get started with it: Getting started with WildFly

wildfly hello world jboss hello world

Next, we will create a project using a Maven archetype to bootstrap a Web application project. You can use one simple like the following one:

mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes \
-DarchetypeArtifactId=webapp-javaee7 \
-DgroupId=com.mastertheboss -DartifactId=helloworld \
-Dversion=1.1 -Dpackage=com.mastertheboss \
-Darchetype.interactive=false --batch-mode --update-snapshots \

Now, let’s configure the project dependency file (pom.xml) so that we can include REST Endpoints in it:

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <name>Demo REST Service</name>


Are you using Gradle to build your project? No worries, check out this tutorial: Gradle tutorial for WildFly users

Then let’s build the Hello World example. We basically need three items:

A simple Model Class:

package com.mastertheboss.jaxrs.model;

import javax.xml.bind.annotation.XmlRootElement;

public class SimpleProperty {
	public SimpleProperty() {

	private String key;
	private String value;

	public SimpleProperty(String key, String value) {
		this.key = key;
		this.value = value;
	public String getValue() {
		return value;
	public void setValue(String value) {
		this.value = value;

	public String getKey() {
		return key;
	public void setKey(String key) {
		this.key = key;

The we need a REST Endpoint:

package com.mastertheboss.jaxrs.service;

import com.mastertheboss.jaxrs.model.SimpleProperty;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

public class HelloService {
	public String getHello () 
		return "hello world!";
	public SimpleProperty getPropertyJSON ()
        SimpleProperty p = new SimpleProperty("key","value");
		return p;
	public SimpleProperty getPropertyXML () 
        SimpleProperty p = new SimpleProperty("key","value");
		return p;

And finally, a REST Activator class, that will expose our services under the /rest Path:

package com.mastertheboss.jaxrs.activator;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

public class JaxRsActivator extends Application {

That’s all. As we have included the Maven WildFly plugin in the project, let’s build and deploy it with:

$ mvn install wildfly:deploy

Now we can test all available endpoints. The first one will just return a text String:

$ curl http://localhost:8080/helloworld/rest/hello/text
hello world!

The second endpoint produces a JSON output:

$ curl http://localhost:8080/helloworld/rest/hello/json

And finally, the last one produces an XML output:

$ curl http://localhost:8080/helloworld/rest/hello/xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><simpleProperty><key>key</key><value>value</value></simpleProperty>

That’s all! Congratulations, you have just mastered the Hello World WildFly tutorial

Source code: https://github.com/fmarchioni/mastertheboss/tree/master/javaee/helloworld