Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wesleyjconnorsesame opened this issue Jan 19, 2021 · 15 comments

Comments

@wesleyjconnorsesame
Copy link

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

@ChristianGmw
Copy link

ChristianGmw commented Jan 22, 2021

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

@rajurathi1112
Copy link

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

@rajurathi1112
Copy link

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

opentracing.spring.cloud.feign.enabled=false

@markusjevringsesame
Copy link

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

@bourd0n
Copy link

bourd0n commented Jun 10, 2021

+1, facing same issue

@xuym-inhand
Copy link

+1

@henriquels25
Copy link

This is the same issue as opentracing-contrib/java-spring-jaeger#127 and the author has opened the PR #324 that solves the problem.

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

@ripper2hl
Copy link

ripper2hl commented Aug 7, 2021

Same problem any workaround to fix this ?

	@Bean
	public Client feignClient(CachingSpringLoadBalancerFactory cachingFactory, SpringClientFactory clientFactory) {
		return new LoadBalancerFeignClient(new OkHttpClient(), cachingFactory, clientFactory);
	}

@davidje13
Copy link

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 {}

@zevolution
Copy link

zevolution commented Sep 15, 2021

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 {}

It worked for me! Thanks so lot @davidje13

@ericomonteiro
Copy link

ericomonteiro commented Jan 26, 2022

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>

xiaobin80 pushed a commit to xiaobin80/microservices-consul that referenced this issue Jun 2, 2022
@rs-asankpal
Copy link

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 {}

Thank you @davidje13, this worked for me

@sepala7
Copy link

sepala7 commented Nov 22, 2022

facing same issue

@zhaozhi406
Copy link

this class seems has been replaced by org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient

@moviewang
Copy link

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

opentracing.spring.cloud.feign.enabled=false

it works, But at the same time, we also lost the track from openfeign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests