IntelliJ Idea Bug in 2016.1.2

I hit a bug in Idea 2016.1.2 that I wanted to share in case anyone else is hitting the same issue. I was trying to stand up a new Spring Boot project last week and when I what try to launch the app through the IDE the embedded tomcat server would throw an exception.

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at com.chooseenergy.auth.AuthApplication.main(AuthApplication.java:14) [classes/:na]Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
... 8 common frames omitted

The weird thing was if I ran the maven spring-boot:run plugin the app ran perfectly. I did all sorts of things with no luck to work around it. I starting worrying about it, thinking if I can’t find a solution to this, it is going to be hard to sell using Spring Boot for our Microservices in my new role as we can’t even properly debug them. Finally after no luck I opened a bug against Idea over here. As is often the case, just the simple act of reporting the bug gets me thinking about possibilities and I solved the issue before I heard back from JetBrains. It turns out that the provided scope is broken in Idea and by default the spring-boot-starter-tomcat is marked scope provided in the generated maven pom file from the Spring Boot Initializer. As soon as I removed the provided scope Idea got happy. Jetbrains later updated the ticket as a duplicate of a bug with provided scope not working. So if you see that stack trace in Idea try removing the provided scope to work around it.