When migrating my app from Spring Boot 2.0.5 to 2.1.0 my application doesn't start anymore.
This is the full stacktrace:
Exception in thread "main" java.lang.AbstractMethodError: Receiver class org.springframework.boot.context.config.ConfigFileApplicationListener does not define or inherit an implementation of the resolved method abstract supportsSourceType(Ljava/lang/Class;)Z of interface org.springframework.context.event.SmartApplicationListener.
at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:81)
at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:295)
at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:225)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:196)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:133)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
@mplanchant reported the same problem on Gitter. As @bclozel suspected there, this is probably caused by having mismatched versions of some dependencies. Do you have Spring Framework 5.1.2 on the classpath?
You're right, the class ConfigFileApplicationListener references the SmartApplicationListener interface from spring-context 5.0.8.RELEASE, which seems to be the problem. I'll investigate a little further.
It looks like the problem is spring-boot-starter-web.
Partial output of mvn dependency:tree:
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.1.0.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.1.0.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.0.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.0.RELEASE:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.1:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.23:runtime
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.1.0.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.6:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.6:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.6:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.0.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.12:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.12:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.12:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.13.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] | +- org.springframework:spring-web:jar:5.0.8.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.0.8.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.0.8.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.0.8.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:5.0.8.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.0.8.RELEASE:compile
As you can see it transitively includes org.springframework:spring-web:jar:5.0.8.RELEASE:compile.
Are you using spring-boot-starter-parent or importing spring-boot-dependencies? That dependency tree tells me that Boot's dependency management isn't in effect, or it's in effect but being overridden.
Ok, now I got it.
I have spring-boot-starter-parent included
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
but also
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config</artifactId>
<version>2.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
If I remove the dependencyManagement block the application starts.
Thanks, so as suspected the dependency management is being overridden. For compatibility with Spring Boot 2.1, I believe you should be using Spring Cloud Greenwich. Creating a project on https://start.spring.io is a good way to see how to set things up.
I generated a SCCS server at https://start.spring.io as suggested but it still does not run.
No errors or exceptions.
Same thing when run from the IDE.
@datamaskin If you are literally seeing no errors or exception then you have a different problem to the one described here. If you鈥檙e looking for some guidance, I鈥檇 recommend asking on Stack Overflow with a minimal example of how to reproduce the problem. If you believe you鈥檝e found a big, please open a Spring Cloud issue. Either way, please comment here with a link so that others can follow the trail.
You can use something like the below to fish for discrepancies:
windows
mvn dependency:tree | findstr spring-core
linux
mvn dependency:tree | grep spring-core
Most helpful comment
Ok, now I got it.
I have
spring-boot-starter-parentincludedbut also
If I remove the
dependencyManagementblock the application starts.