2
votes

The project spring boot 1..5.7 release. I am using Intellij IDEA 2017.2.4 and gradle for dependency management. When i build the project it builds successfully with no error. When I run the application with bootRun gradle task it shows the following error.

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:413)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392)
    at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:378)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:291)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.kifiya.lmanagement.LmanagementApplication.main(LmanagementApplication.java:13)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.event.EventPublishingRunListener]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:409)
    ... 6 more
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
    at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105)
    at org.springframework.boot.context.event.EventPublishingRunListener.(EventPublishingRunListener.java:56)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
    ... 7 more
3
did you resolved it?devanathan

3 Answers

1
votes

It looks like spring-aop doesn't match the rest of your libraries. Try running gradle dependencies and check that all Spring dependencies are in the same version. More on inspecting dependencies in Gradle User Manual.

1
votes

It seems like a dependency problem within Spring, as it's mentioned above. The easiest way IMHO is to check your POM file.

Check out here for more info: https://docs.gradle.org/current/userguide/introduction_dependency_management.html

1
votes

Old question, but I had the same error after converting a Spring application to Spring Boot. Using the spring-boot-starter-aop instead of a direct dependency on a specific version of spring-aop resolved it for me, e.g. in build.gradle:

plugins {

    id 'org.springframework.boot' version '1.5.17.RELEASE'
}

apply plugin: 'io.spring.dependency-management'

dependencies {

    compile 'org.springframework.boot:spring-boot-starter-aop' 

}

instead of

dependencies {

    compile 'org.springframework:spring-aop:4.2.4.RELEASE'
}