java-spring-cloud icon indicating copy to clipboard operation
java-spring-cloud copied to clipboard

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

Open wesleyjconnorsesame opened this issue 4 years ago • 15 comments

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

wesleyjconnorsesame avatar Jan 19 '21 14:01 wesleyjconnorsesame

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

ChristianGmw avatar Jan 22 '21 12:01 ChristianGmw

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

rajurathi1112 avatar Mar 08 '21 10:03 rajurathi1112

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

opentracing.spring.cloud.feign.enabled=false

rajurathi1112 avatar Mar 08 '21 23:03 rajurathi1112

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

markusjevringsesame avatar May 26 '21 08:05 markusjevringsesame

+1, facing same issue

bourd0n avatar Jun 10 '21 16:06 bourd0n

+1

xuym-inhand avatar Jun 16 '21 09:06 xuym-inhand

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.

henriquels25 avatar Jul 31 '21 21:07 henriquels25

Same problem any workaround to fix this ?

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

ripper2hl avatar Aug 07 '21 02:08 ripper2hl

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

davidje13 avatar Sep 07 '21 16:09 davidje13

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

zevolution avatar Sep 15 '21 12:09 zevolution

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

AhHa45 avatar Sep 17 '21 08:09 AhHa45

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>

ericomonteiro avatar Jan 26 '22 04:01 ericomonteiro

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

rs-asankpal avatar Sep 01 '22 22:09 rs-asankpal

facing same issue

sepala7 avatar Nov 22 '22 07:11 sepala7

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

zhaozhi406 avatar Feb 14 '23 05:02 zhaozhi406