An example project showing the problems deploying Spring Boot applications to Wildfly in an EAR deployment using skinny WARs.
This project consists of two web applications using Spring Boot, web1 and web2, and an EAR containing the two applications
packaged as skinny WARs to avoid duplicating the dependencies and to speed up deployment.
- Wildfly does not find
SpringServletContainerInitializerif it is in the EARlibdirectory. This is discussed on https://issues.jboss.org/browse/WFLY-4205 and https://jira.spring.io/browse/SPR-12555. A fix should be in 9.0.0.Beta1 upwards, but it did not work for me. So I had to create theservlet-container-initializer-meta-infmodule and force it to be included in eachWEB-INF/libdirectory. - When
SpringServletContainerInitializeris called it does not find Spring BootWebApplicationInitializerclasses inWEB-INF/classes. When it interrogates the class loader, it only finds classes from the EARlibfolder. However, the WAR classes are on the class path and are found by Spring once it starts up. As a temporary work-around, I created a common Spring Boot application class and included it as a common JAR.
Spring loads a completely separate context for each WAR. I would like it to share a root context to speed up loading and allow for shared components. There is an unanswered question on Stack Overflow http://stackoverflow.com/questions/31667392/spring-boot-ear-packaging and I have not yet found a solution.
- Download Wildfly 9.0.2.Final
- Build the project using
mvn clean package - Deploy the web-all.ear file to Wildfly.
You should be able to hit http://localhost:8080/web1 and http://localhost:8080/web2