opentracing-contrib/java-spring-cloud

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

wesleyjconnorsesame opened this issue ยท 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

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

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

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

opentracing.spring.cloud.feign.enabled=false

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

+1, facing same issue

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.

Same problem any workaround to fix this ?

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

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

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

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>

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

facing same issue

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

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.