Spring cloud sleuth dependencies throwing RibbonLoadBalancerClientException in Spring boot stack application - spring-boot

We are planning to integrate spring sleuth in our Spring cloud microservices application. However when a Service A makes a call to Service B using RestTemplate we are getting RibbonLoadBalancerClient exception. Please find the stack trace below.
ResponseObject genericResponse = restTemplate.exchange(expandedUrl, HttpMethod.GET, new HttpEntity<>(null), ResponseObject.class).getBody();
Logger.log(DEBUG, "getDetails returned {} ", response);
return genericResponse.getData().getInformation();
The version are are using is as below
Spring Boot : springBootVersion = '1.5.3.RELEASE'
Spring Sleuth : spring-cloud-starter-sleuth:1.2.4.RELEASE
Spring cloud dependencies : spring-cloud-services dependencies:1.2.0.RELEASE,
spring-cloud-dependencies:Brixton.RELEASE
Exception - stacktrace :
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.AbstractMethodError: org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(Ljava/lang/String;Lorg/springframework/cloud/client/ServiceInstance;Lorg/springframework/cloud/client/loadbalancer/LoadBalancerRequest;)Ljava/lang/Object;| at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:978)| at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)| at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)|

You should be using the release train to manage versions. Also Brixton is a very old release train. Please upgrade and don't set library versions manually.

Related

Springboot- oauth2 - websockets - Service Unavailable for async support

I have a springboot app , outh2 secure and now integrating websockets.
When I try connect , I get the error
Caused by:
org.springframework.web.socket.sockjs.SockJsTransportFailureException:
Failed to open session; nested exception is
java.lang.IllegalArgumentException: Async support must be enabled on a
servlet and for all filters involved in async request processing. This
is done in Java code using the Servlet API or by adding
"true" to servlet and filter
declarations in web.xml. Also you must use a Servlet 3.0+ container
As my app is springboot , and without web.xml. I added the below bean
#Bean
public ServletRegistrationBean dispatcherServlet() {
ServletRegistrationBean registration = new ServletRegistrationBean(new DispatcherServlet(), "/");
registration.setAsyncSupported(true);
return registration;
}
Now the new error is HTTP ERROR 503 Service Unavailable
The posts both didn't solve my problem
How to enable async support in a Springboot application packaged and deployed as WAR
Spring: Servlet 3.1 + SockJS = Async support must be enabled
How can I enable async and resolve my problem ?

NoSuchMethodError when trying to map Kafka binder to input method

The following is prompted in console when trying to launch a spring cloud streams project with the Kafka binder active:
org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle';
Caused by: java.lang.NoSuchMethodError: java.util.List.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;
My input method goes as follows using Spring Cloud functions:
#Bean
public Function<Message<String>, byte[]> exec() {
return input -> ...
Now, having Kafka in place, my .properties file looks as follows:
spring.cloud.stream.function.bindings.exec-in-0=in
spring.cloud.stream.bindings.in.destination=topic-0
spring.cloud.stream.function.bindings.exec-out-0=out
spring.cloud.stream.bindings.out.destination=topic-1
spring.cloud.stream.bindings.in.binder=kafka
spring.cloud.stream.kafka.bindings.in.consumer.configuration.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.cloud.stream.bindings.out.binder=kafka
spring.cloud.stream.kafka.bindings.out.producer.configuration.value.serializer=org.apache.kafka.common.serialization.ByteArraySerializer
Am I missing any configs for the input method? Should that method be different for Kafka (already tested this with PubSub and it works)?
The error in your stack trace gives us a clue that you are facing this problem: https://github.com/spring-projects/spring-integration/issues/3761.
So, or upgrade to the latest Spring Cloud Stream: https://spring.io/projects/spring-cloud-stream#learn
Or to the latest Spring Integration: https://spring.io/projects/spring-integration#learn
Or just use Java > 8 !

No suitable default RequestUpgradeStrategy found in a new generated jhipster application

I'm working on Jhipster micro-services project, all works fine and good until i a
websocket spring-websocket
into the gateway application in my JDL file, now when I run the project I always get a failure
Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'stompWebSocketHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
the application I'am use is right of the box generated from jhipster generator 7.0.0
the JDL I use is :
application {
config {
baseName usergateway,
packageName fr.teamsyst.trade4talent.usergateway,
applicationType gateway,
authenticationType jwt,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
serviceDiscoveryType eureka,
testFrameworks [protractor],
nativeLanguage fr,
languages [fr, en],
jhiPrefix t4t,
websocket spring-websocket,
}
entities *
}
Add spring-boot-starter-tomcat dependency to pom.xml
Add spring.main.web-application-type: reactive to application.yml

Logging after exception on application start

Using Spring boot 2.0.5. On application start occurs a exception with is logged 'ConfigServletWebServerApplicationContext : Exception encountered during context initialization'. But i need stacktrace. I was expecting stack trace will be logged later in SpringApplication.reportFailure '"Application run failed"'. But spring boot calls before this method ServletWebServerApplicationContext.stopAndReleaseWebServer and its seems that after this call any logging does not work anymore.
this can be related to your issue: spring boot discussion
spring boot github issue
You can also debug SpringApplication#reportFailure in the end (after catch (throwable)) it has generic logging of any error:
logger.error("Application run failed", ex)
In my case I had the logger from commons-logging which prevented logging to happen.

IllegalStateException in ExposeInvocationInterceptor after upgrading to Spring 4.1.x

After upgrading to Spring 4.1.4 and Spring Data Jpa 1.7.1 (from 4.0.2 and 1.5.1, respectively) I started to get IllegalStateException from ExposeInvocationInterceptor#currentInvocation()
At first I thought it could be somehow related to the following fix https://jira.spring.io/browse/SPR-12351 but I got the same exceptions also with Spring 4.1.1.
Any ideas what could be the problem?
Below is an excerpt from the exception stack trace:
java.lang.IllegalStateException: No MethodInvocation found: Check that an AOP invocation is in progress, and that the ExposeInvocationInterceptor is upfront in the interceptor chain. Specifically, note that advices with order HIGHEST_PRECEDENCE will execute before ExposeInvocationInterceptor!
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.currentInvocation(ExposeInvocationInterceptor.java:73)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$ThreadBoundTargetSource.createObject(CrudMethodMetadataPostProcessor.java:226)
at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:86)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:187)
at com.sun.proxy.$Proxy112.getLockModeType(Unknown Source)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findOne(SimpleJpaRepository.java:224)
...

Resources