Spring Cloud Kubernetes Loadbalancer issue with Spring Boot 2.6.6 - spring-boot

I am using spring boot 2.6.6 and spring cloud 2021.0.2 version with spring cloud kubernetes loadbalancer and spring cloud kubernetes all.
But I am getting error Application failed to start below are the dependencies
<properties>
<spring-cloud.version>2021.0.2</spring-cloud.version>
<spring-boot.version>2.6.6</spring-boot.version>
</properties>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-all</artifactId>
<version>1.1.10.RELEASE</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-kubernetes-dependencies</artifactId>
<version>1.1.10</version>
</dependency>
</dependencies>
</dependencyManagement>
Error:
2022-05-24 01:05:51.399 ERROR 14884 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.loadbalancer.config.LoadBalancerCacheAutoConfiguration$DefaultLoadBalancerCacheManagerConfiguration.defaultLoadBalancerCacheManager
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.6.6.jar:2.6.6]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:193) ~[spring-context-5.3.18.jar:5.3.18]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:153) ~[spring-context-5.3.18.jar:5.3.18]
Process finished with exit code 1
Please if someone can help to understand what is the going wrong here.
Any help is much appreciated.
Thanks !!

Thanking all to share your views via comments. I have figured out the answer.
I see below dependency seems to be working fine with latest spring boot 2.6.6 or 2.7.0
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-fabric8-all</artifactId>
<version>2.1.2</version>
</dependency>
It seems this is similar to what below ones use to provide, such as config or load balancer etc. certainly the dependencies are renamed as you can see.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-all</artifactId>
<version>1.1.10.RELEASE</version>
</dependency>

Related

What GCP dependencies and versions for Spring Boot 2.5.14 Integration

I'm pretty bad with java and trying to get an older spring boot app moved into GCP. I have a proof of concept app working using spring-boot 3.0.1 and spring-cloud-gcp-starter-secretmanager#3.4.1. It runs fine and pulls secrets from Secret manager like a charm.
Pom snippet:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>edu.mayo</groupId>
<artifactId>secret-manager-poc</artifactId>
<version>1.0.0</version>
<name>secret-manager-poc</name>
<description>Spring boot POC with GCP secret manager</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>
I'm trying to do the same thing in my older spring-boot app and getting really confused. Here is what I have for dependancies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.14</version>
<relativePath></relativePath>
</parent>
...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2020.0.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
When I started loooking at what versions of the secretmanager starter I should use I came across this: https://spring.io/projects/spring-cloud Which makes it looks like I should used 2020.0.6 but then I've noticed that there are two groupIds org.springframework.cloud vs com.google.cloud, and I've been searching through posts and articles but I'm confused as hell. When I try run mvn clean install I get this message:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:jar is missing. # line 158, column 15
Its complaining bout the version attribute being missing on the starter library, but all the docs I'm reading say that this should work.
mvn --version
Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)
Maven home: C:\Program Files\apache-maven-3.8.7-bin\apache-maven-3.8.7
Java version: 17.0.5, vendor: Microsoft, runtime: C:\Program Files\Microsoft\jdk-17.0.5.8-hotspot
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Which dependencies and versions should someone use to connect to GCP secret manager from a springboot 2.5.14 app?
EDIT / UPDATE.
Currently able to start Spring boot with these dependancies with spring-boot 2.5.14:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>4.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
however my properties aren't being retreived from secret manager. I have this property file:
# General settings
api.version: #project.version#
# Akana settings
akana.secret.name=akana-shared-secret
akana.secret.hash=${sm://mde-akana-secret-hash}
...
But after spring-boot starts and I go to manage/env to print the env variables I see this:
"akana.secret.hash":{"value":"//mde-akana-secret-hash"}
all of the properties that are defined like this:
prop.name=${sm://sm-key}
are loaded into context like this:
prop.name=//sm-key
any idea what I'm missing?
Which dependencies and versions should someone use to connect to GCP secret manager from a springboot 2.5.14 app?
None.
After wasting today trying to figure out which dependency versions of both google and spring provided dependencies I needed to get spring boot to talk to GCP secrets manger, I happened across this random video. https://youtu.be/mRSJmHlkzck. After pausing it and transposing parts of the pom, I finally got the app to kick over and generate this lovely message:
***************************
APPLICATION FAILED TO START
***************************
Description:
Your project setup is incompatible with our requirements due to following reasons:
- Spring Boot [2.5.14] is not compatible with this Spring Cloud release train
Action:
Consider applying the following actions:
- Change Spring Boot version to one of the following versions [2.3.x, 2.4.x] .
You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn].
If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]
So I downgraded to springboot 2.4.13 and got it to work. Here are the relevant dependencies and versions:
<properties>
...
<spring-cloud-gcp.version>2.0.5</spring-cloud-gcp.version>
<spring-cloud.version>2020.0.1</spring-cloud.version>
</properties>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>${spring-cloud-gcp.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Then you'll need this in a bootstrap.properties file:
spring.cloud.gcp.secretmanager.bootstrap.enabled=true
spring.cloud.gcp.secretmanager.secret-name-prefix=sm://

Unable to find zuul properties in application.yml

Unable to find below zuul properties in application.yml attached the pom.xml.
I hope I added the necessary dependency or do I missing anything.
How to connect the services with gateway.
application.yml
zuul.routes.hello.path=/hello/**
zuul.routes.hello.serviceId=Beginner-Microservice
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
The reference link
https://javabeginnerstutorial.com/spring-boot/spring-boot-2-microservices-with-netflix-zuul-api-gateway/
The spring cloud version which I have used is
<spring-cloud.version>Finchley.M8</spring-cloud.version>
Kindly help me in this regard

Spring Boot 2 fails starting due to Hystrix?

I started investigating to migrate a Spring Boot application from 1.5.x to 2.
This appliication has a dependency to hystrix, which does not be compatible to Spring Boot 2 yet.
When I have the following in my pom:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.4.RELEASE</version>
</dependency>
I get the following error when starting the application:
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:125)
Anybody has experienced the same?
Is there a solution yet?
I have faced similar issue while integrating hystrix for my spring boot microservice that uses spring boot 2.0.x.
Instead of
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>${spring-hystrix.version}</version>
</dependency>
I have moved to
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>${spring-hystrix.version}</version>
</dependency>
Spring boot 2.0.x application starts fine with the spring-cloud-starter-netflix-hystrix dependency without this issue.
For SpringBoot 2.0 version artifactID has been changed. Old dependency is
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>${spring-hystrix.version}</version>
</dependency>
Use this new updated dependency with latest version
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
for recent release version you can check MVNrepository
After a bit further research I found a solution by adding the following to the pom file:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
all versions of spring-cloud-dependenciesseem to be incompatible to Spring Boot 2.x.x
I had this problem starting Spring Boot 2 as well because spring-cloud-starter-hystrix was a dependency I used in my project. However I found that spring-cloud-starter-hystrix has been deprecated. I also found the feign classes I was using in there have been moved to spring-cloud-openfeign (https://github.com/spring-cloud/spring-cloud-openfeign). So all I did was remove spring-cloud-starter-hystrix from my dependency and added spring-cloud-openfeign instead. This works perfectly for me.
Basically I replaced
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-hystrix', version: '1.4.4.RELEASE'
with
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.0.0.RELEASE'
and Spring Boot 2 is ready to go. Hope this helps.
NB: I use Gradle, you can easily find the maven pom dependency equivalents if necessary.
I faced a similar problem with Spring Boot 2, concisely 2.2.0.RELEASE. My mvn project compiled well but Spring Boot application stopped starting, without showing any real hints.
The solution that worked was using the artifact spring-cloud-starter-netflix-hystrix instead of spring-cloud-starter-hystrix from the same group. Then you can use the same same version as Spring Boot to retrieve the dependency.
From old pom.xml :
<!-- hysterix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
New part in working pom.xml:
<!-- hysterix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>${spring.boot.version}</version>
</dependency>
After some time spent on researching and testing, here is what I found and noticed
I think that in the latest Spring Boot version (2.5.x), the Hystrix looks to be deprecated or I just couldn't find out way to add it as a dependency.
So I downgraded the Spring boot version to 2.3.x where I managed to run the application
So here is how my working pom.xml looks like:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.hldservices</groupId>
<artifactId>payment-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringCloudPaymentCircuitBreakerApplication</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Hoxton.SR11</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Keep in mind that I had to add following configuration in my Project:
SpringCloudPaymentCircuitBreakerApplication(main class)
#EnableHystrix
#EnableHystrixDashboard
application.propreties
management.endpoints.web.exposure.include=*
hystrix.dashboard.proxyStreamAllowList=*

Application insight configuration for spring boot is not working

I am using spring boot version 2.0.0.
and I am using applicationInsight-web and core jar 2.1.0.
I have put instrumantation key in applicaionInsight.xml also.
Please refer to https://learn.microsoft.com/en-us/azure/application-insights/app-insights-java-get-started#4-add-an-http-filter
It shows how to configure Application Insights Java SDK for SpringBoot Applications.
Here are the configurations for me to make Spring-cloud + Azure Application Insight.
pom.xml
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>1.2.0-BETA</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-logback</artifactId>
<version>2.4.0-BETA</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.brave</groupId>
<artifactId>brave-opentracing</artifactId>
</dependency>
and dependenciesManagement
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>1.1.0.RC5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
logback-spring.xml
<appender name="aiAppender"
class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
<instrumentationKey>YOUR_INSTRUMENTATION_KEY</instrumentationKey>
</appender>
application.yml
azure:
application-insights:
instrumentation-key: YOUR_INSTRUMENTATION_KEY
Good luck!

spring cloud version Brixton.SR5 with spring boot 1.4

I have a new project that we are doing with spring Brixton.SR1...
and Brixton.SR1 or SR5 is built on 1.3.5.RELEASE but forum says it has been tested with 1.4.0.RELEASE and thus i want to use some features of 1.4.0.
<dependencyManagement>
<dependencies>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
..
</dependencyManagement>
And then we are adding dependencies and are all default versions are used eg.. spring boot is 1.3.5.RELEASE, so current structure is as given below.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
....
But i want to use 1.4.0 . Can i exclude 1.3.5 version and use this new version....and i dont want to overwritte this for all spring boot artifacts . eg.. as given below
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
and so on so forth..
rather want to have a common version for spring-boot artifact and which should give default versions to all spring artifacts as 1.4.0
just import spring boot's 1.4 bom and spring cloud's bom into your pom.xml:
<dependencyManagement>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Resources