Kiran
Kiran

Reputation: 879

Unable to start spring boot application NoClassDefFoundError

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)

Upvotes: 2

Views: 6780

Answers (2)

Andy Wilkinson
Andy Wilkinson

Reputation: 116291

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.

Upvotes: 2

JaisAnkit
JaisAnkit

Reputation: 154

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.

Upvotes: 0

Related Questions