Building a Spring Boot RESTful Web Service for Wildfly 8.2

The Spring Boot project promises a easy and fuss free way to build and configure Spring applications. I finally got a chance to try it out today. I needed to build a simple RESTful Web Service to deploy on Wildfly 8.2.

I followed the tutorial at The tutorial was written for an embedded web server. I needed to make a few tweaks to get my app running on Wildfly.

By adding


to pom.xml, I was able to generate a war file using mvn package. However, when I deployed the war file in Wildfly, I got the following exception:

      org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to

Spring boot packaged tomcat jars into the war file and they conflicted with Wildfly. I then added the following exclusions to pom.xml.


After this change, the web app deployed and started, but could not receive any requests. All GET requests returned 403 forbidden and POST requests returned 405 method not allowed. There was nothing in the log files indicating what was wrong. After a bit of head banging I found out the problem was Wildfly couldn’t forward requests to the web app! I needed to

  1. include servlet-api jars, and
  2. annotate the main class with @ComponentScan and make it a subclass of SpringBootServletInitializer
    public class Application extends SpringBootServletInitializer {
        public static void main(String[] args) {
  , args);

That’s it! I was impressed by how little configuration I needed to get my app up and running.

Note: I was using Spring Boot version 1.3.3