Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2 upgrade java.lang.ClassNotFoundException: EmbeddedServletContainerCustomizer

I recently upgraded to Spring Boot 2, our app is deployed out through Bamboo onto PCF the build runs fine however during the deployment stage I receive the following error:

java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer

We aren't using the EmbeddedServletContainerCustomizer class anywhere in the code and I can't figure out where this is coming from. Wondering if this is a pom issue?

I have tried all other questions on here of a similar nature.

like image 957
Rebecca Douglas Avatar asked Oct 17 '25 09:10

Rebecca Douglas


2 Answers

org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer was removed from spring-boot dependency in 2.X. Most likely you haven't updated the dependencies fully and there is a dependency that refers to spring-boot-1.X somewhere in your build.

The fact that it works on Bamboo implies that your CI is polluted and doesn't reflect the deployment environment.

like image 139
Karol Dowbecki Avatar answered Oct 18 '25 23:10

Karol Dowbecki


This issue turned out to be caused by our packaging of the spring app into a war which requires implementing the SpringBootServletInitializer class to override the configure method:

@Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
      return application.sources(WebApplication.class);
  }

This in turn was throwing the above error. Taking steps now to remove this and package our app as a jar instead!

like image 21
Rebecca Douglas Avatar answered Oct 18 '25 23:10

Rebecca Douglas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!