java-spring-cloud: NoClassDefFoundError: org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient when using spring-cloud-dependencies:2020.0.0

Using implementation "io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:3.2.2" I upgraded to the new mavenBom "org.springframework.cloud:spring-cloud-dependencies:2020.0.0"

spring-cloud ‘Hoxton.SR9’ worked correctly

Since then I get the following error on startup. It seems ribbon was removed from spring cloud in 2020 but is required by jaeger (but not included) with spring-jaeger

Removing spring-jaeger and my application works correctly with spring-cloud 2020

It looks like simply updating the cloud version in java-spring-cloud is not so easy, is a migration planned?

Caused by:
  java.lang.NoClassDefFoundError: org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient
      at io.opentracing.contrib.spring.cloud.feign.TracedFeignBeanFactory.from(TracedFeignBeanFactory.java:40)
      at io.opentracing.contrib.spring.cloud.feign.TraceFeignContext.addTracingClient(TraceFeignContext.java:64)
      at io.opentracing.contrib.spring.cloud.feign.TraceFeignContext.getInstance(TraceFeignContext.java:46)
      at org.springframework.cloud.openfeign.FeignClientFactoryBean.get(FeignClientFactoryBean.java:272)
      at org.springframework.cloud.openfeign.FeignClientFactoryBean.feign(FeignClientFactoryBean.java:99)
      at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:325)
      at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:315)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:169)
     ... 149 more

a

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 34
  • Comments: 15

Commits related to this issue

Most upvoted comments

fyi , after adding below in property file , we are not seeing this error . hope this helps …

opentracing.spring.cloud.feign.enabled=false

instead of this hacky workaround I’d simply exclude opentracing-spring-cloud-feign-starter from your build. This solved the issue for me.

As a really nasty workaround in the meantime, I believe you can resolve this by defining the classes which it is looking for. This should be safe, because it won’t actually use them (it just does an instanceof LoadBalancerFeignClient check which will of course fail because nothing will create one)

With that in mind, adding the following files in the correct packages “works”:

package org.springframework.cloud.openfeign.ribbon;

import feign.Client;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;

public class LoadBalancerFeignClient {
    public LoadBalancerFeignClient(Client delegate, CachingSpringLoadBalancerFactory lbClientFactory, SpringClientFactory clientFactory) {
        throw new UnsupportedOperationException();
    }

    public Client getDelegate() {
        throw new UnsupportedOperationException();
    }
}
package org.springframework.cloud.netflix.ribbon;

public class SpringClientFactory {}
package org.springframework.cloud.openfeign.ribbon;

public class CachingSpringLoadBalancerFactory {}

I resolved this problem adding this dependency

<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-openfeign-core</artifactId>
	<version>2.2.6.RELEASE</version>
</dependency>

I am facing similar issue. is there any timeline to support SpringCloud 2020.0.0 ?

I can confirm the issue. We ran into the same problem when we tried to upgrade to SpringBoot 2.4.x with SpringCloud 2020.0.0

spring-cloud-netflix-ribbon has been removed from SpringCloud with this version: https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2020.0-Release-Notes#breaking-changes

facing same issue

What’s the status on supporting getting this working in spring 2.4 or 2.5? What’s required? How can we help?

This is the same issue as https://github.com/opentracing-contrib/java-spring-jaeger/issues/127 and the author has opened the PR https://github.com/opentracing-contrib/java-spring-cloud/pull/324 that solves the problem.

I believe we should merge the PR because the issue affects everyone who upgraded Spring Boot and uses OpenFeign.