2

I have changed spring-boot-starter-parent from 1.4.3 to 1.5.4

   <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
    </parent>

This is my java application file

 @SpringBootApplication
    @ComponentScan("com.test")
    @EnableCaching
    @EnableAsync
    @EnableAspectJAutoProxy
    @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, WebMvcAutoConfiguration.class })
public class Application {

when I start my server it is throwing below error. As per the dependencies it should take care of dependent jars like spring-boot

Any help is appreciated.

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ErrorPage
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:73)
    at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:59)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1581)
Kiran
  • 839
  • 3
  • 15
  • 45
  • Why are you excluding `DataSourceAutoConfiguration` and `WebMvcAutoConfiguration`? Probably some dependency of the embedded tomcat is not being configured properly. If you want to override some of the auto configuration you can extend the corresponding Adapter classes without rewriting the whole configuration manually – SrThompson Mar 08 '18 at 20:09
  • 1
    @SrThompson Excluding DataSource and AutoConfiguration does not impact tomcat configuration. – JaisAnkit Mar 08 '18 at 20:43

2 Answers2

2

Some code in the customize method of com.xyz.asr.autoconfigure.asr.tomcat.AsrEmbeddedTomcatCustomizer is referring to the class org.springframework.boot.context.embedded.ErrorPage. The class does not exist in Spring Boot 1.5. The correct fully-qualified name for ErrorPage is org.springframework.boot.web.servlet.ErrorPage.

AsrEmbeddedTomcatCustomizer needs to be updated to use org.springframework.boot.web.servlet.ErrorPage.

Kiran
  • 839
  • 3
  • 15
  • 45
Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
0

Problem is with the Spring version.

Due to spring boot version 1.5.4 and 1.5.2 mixed up in one of the child projects. Issue 9543 was created for it.

Remove the spring-web dependency from the POM file and put spring-boot-starter-web in the POM.

JaisAnkit
  • 154
  • 1
  • 6
  • By issue 9543, I assume you are referring to https://github.com/spring-projects/spring-boot/issues/9543? If so, that's a different problem and the advice doesn't apply here. – Andy Wilkinson Mar 08 '18 at 21:45