A first dive into WildFly 12!

WildFly 12 has been released. Let’s have a quick dive in it!

First of all, download WildFly 12 from http://wildfly.org/downloads

The most significant enhancement in WildFly 12 is the Java EE 8 preview profile which can be activated by passing the “ee8.preview.mode” property during startup:

$ ./standalone.sh -Dee8.preview.mode=true

Alternatively, a new configuration has been added to the standalone folder so that it can be started directly using the Java EE 8 preview mode:

$ ./standalone.sh -c standalone-ee8.xml

One of the enhancements in Java EE 8 is the introduction of Servlet 4.0 specification. This includes several adds-on but the most interesting one is the PushBuilder interface which is designed for the HTTP/2 Server Push feature (JSR 369).

Here is a sample Servlet which used the PushBuilder interface to push dynamically an image contained in the “images” folder of the Web application:

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.PushBuilder;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(value = {"/push"})
public class Http2Servlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PushBuilder push = request.newPushBuilder();
        if (push != null) {
                    .addHeader("content-type", "image/png")

        try (PrintWriter writer = response.getWriter();) {
            writer.write("<html><img src='images/demo.png'></html>");


Please notice that in order to build this class you will need to include the jboss-servlet-api_4.0_spec artifact in your pom.xml:


Verify that your Web application correctly deploys to WildFly 12 and invoke it through the http://[server:port]/[webcontext]/push