spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.87k stars 2.44k forks source link

Zuul: Not specifying stripPrefix results in com.netflix.client.ClientException #2022

Closed benneq closed 7 years ago

benneq commented 7 years ago

I'm using Spring Boot 2.0.0 M1 and Spring Cloud Finchley.BUILD-SNAPSHOT

Really strange behavior. My Zuul Config looks like this:

zuul:
  ignoredServices: '*'
  routes:
    articles:
      path: /articles/**
      serviceId: articles
      stripPrefix: true

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:9092/eureka/

When I set stripPrefix to true or false everything works as expected.

But when I don't specify it, every call to /articles/... results in an exception:

Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: articles.path
    at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483) ~[ribbon-loadbalancer-2.2.2.jar:2.2.2]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184) ~[ribbon-loadbalancer-2.2.2.jar:2.2.2]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180) ~[ribbon-loadbalancer-2.2.2.jar:2.2.2]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber$1.call(OperatorRetryWithPredicate.java:127) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.enqueue(TrampolineScheduler.java:73) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.schedule(TrampolineScheduler.java:52) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:79) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:45) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:276) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Subscriber.setProducer(Subscriber.java:209) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:138) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:129) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.subscribe(Observable.java:10352) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.subscribe(Observable.java:10319) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:443) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.observables.BlockingObservable.single(BlockingObservable.java:340) ~[rxjava-1.3.0.jar:1.3.0]
    at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:117) ~[ribbon-loadbalancer-2.2.2.jar:2.2.2]
    at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:105) ~[spring-cloud-netflix-core-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
    at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:43) ~[spring-cloud-netflix-core-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
    at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302) ~[hystrix-core-1.5.11.jar:1.5.11]
    at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298) ~[hystrix-core-1.5.11.jar:1.5.11]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.subscribe(Observable.java:10352) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.Observable.subscribe(Observable.java:10319) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.internal.operators.BlockingOperatorToFuture.toFuture(BlockingOperatorToFuture.java:51) ~[rxjava-1.3.0.jar:1.3.0]
    at rx.observables.BlockingObservable.toFuture(BlockingObservable.java:410) ~[rxjava-1.3.0.jar:1.3.0]
    at com.netflix.hystrix.HystrixCommand.queue(HystrixCommand.java:378) ~[hystrix-core-1.5.11.jar:1.5.11]
    at com.netflix.hystrix.HystrixCommand.execute(HystrixCommand.java:344) ~[hystrix-core-1.5.11.jar:1.5.11]
    at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:152) ~[spring-cloud-netflix-core-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
    ... 63 common frames omitted
ryanjbaxter commented 7 years ago

And this is not a problem in Dalston or Edgware?

benneq commented 7 years ago

I downloaded another sample project and set up a similar configuration to mine. I don't know if it's Dalston or Edgware.

I can tell that It's using spring-cloud-starter-zuul 1.2.3 and spring-boot 1.4.4

This works without specifying stripPrefix.

When I update this project to use Spring Boot 2.0.0 M1 and Finchley.BUILD-SNAPSHOT I again get the exception above.

spencergibb commented 7 years ago

FYI we are not compatible with Spring Boot 2.0.0 M1. only BUILD-SNAPSHOT

spencergibb commented 7 years ago

It doesn't make much sense to me as they are unrelated. Can you try with spring boot snapshots?

benneq commented 7 years ago

I will try Spring Boot Snapshot in a few minutes. Will report soon.

Btw: According to your release schedule Finchley M1 will be out in 6 days. Will this be working with Spring Boot 2.0.0 M1?

spencergibb commented 7 years ago

It will need to be adjusted as we are waiting for Spring Boot 2.0.0.M2

benneq commented 7 years ago

I now deleted my whole ~/.m2/ folder and let maven redownload all snapshot builds.

It downloaded Spring Boot 2.0.0 SNAPSHOT, Spring 5.0.0 SNAPSHOT and Spring Cloud Starter 2.0.0 SNAPSHOT

Now I can't even start, because:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationEvent
    at org.demo.eurekaserver.EurekaServerApplication.main(EurekaServerApplication.java:13)
    at org.demo.app.Application.main(Application.java:12)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationEvent

But this sounds more like a Spring Boot SNAPSHOT bug to me, unrelated to Spring Cloud.

Here's my pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.BUILD-SNAPSHOT</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zuul</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

EDIT the error above was some maven problem, it downloaded a corrupt file. will report the results soon

benneq commented 7 years ago

RESULTS

This seems to work as expected 👍 using Spring Cloud Starter 2.0.0 SNAPSHOT, Spring Boot 2.0.0 SNAPSHOT and Spring 5.0.0 SNAPSHOT

--

Now I'm back at Spring Cloud Starter 2.0.0 SNAPSHOT, Spring Boot 2.0.0 M1 and Spring 5.0.0 RC1 again getting the error from above.

--

Though I guess you can close this, and it will magically work with the next release 👍

Thank you!