Cannot get pass through this error.
Java 11 Gradle 6.2.1
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessorException in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:445) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:427) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420) at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:273) at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:253) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) at ee.hotelliveeb.api.Application.main(Application.java:27)Caused by: java.lang.IllegalArgumentException: class org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor is not assignable to interface org.springframework.context.ApplicationListener at org.springframework.util.Assert.assignableCheckFailed(Assert.java:714) at org.springframework.util.Assert.isAssignable(Assert.java:645) at org.springframework.util.Assert.isAssignable(Assert.java:676) at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:439) ... 7 more
Unfortunately, I cannot provide sample project. I think it will work properly with any new project. My project, however, is quite old and started when Spring boot 2.2.0 have not been released yet. Then some time ago I upgraded to 2.2.0 without any problems and how am trying to upgrade to 2.2.5 and stuck with this error.
I suspect that maybe problem is that different Spring boot versions mess up the flow? I have several servers running in parallel and all using 2.2.0. Now if I will try to put some server to use 2.2.5 then this error will occur. When I upgraded all servers to use 2.2.5 and then cleared gradle cache and mvn repository and managed to get passed that error via multiple cache cleaning, but when a turned one server back to 2.2.0 then error occurred again.
Now in my local environment I can put all servers to 2.2.5 and clear cache and never think about 2.2.0, but when I deploy this upgrade to Bamboo which uses Docker to build new image and run a container I keep getting that error again. And here is where I stuck because I do not get why I get that error. Docker should build image with clear cache.
Comment From: wilkinsona
CloudFoundyVcapEnvironmentPostProcessor has been an ApplicationListener since 2.2.2. It would appear that you have a problem with your classpath and have an up-to-date version of spring.factories that lists it as an ApplicationListener and an out-of-date version of its .class file where it does not implement ApplicationListener.
Unfortunately, there's nothing we can do to fix this in Spring Boot itself as the building of your Docker image and the creation of its classpath is out of our control. To help to diagnose the problem, you may like to run your application with -verbose:class so that you can see from where the out-of-date version of CloudFoundryVcapEnvironmentPostProcessor is loaded.
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
Comment From: gaurav9822
@wilkinsona Was able to solve this by upgrading one jar which was using old CloudFoundyVcapEnvironmentPostProcessor implementing ApplicationListener.