Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-366

Using Template API with a ResponseValidator in Ribbon Example seems to have classpath problems

    Details

    • Steps to Reproduce:
      Hide

      1. Replace the client call EventsResource (Line 50) with the Template Api approach
      2. start all services / client
      3. Try to test services with client

      Show
      1. Replace the client call EventsResource (Line 50) with the Template Api approach 2. start all services / client 3. Try to test services with client

      Description

      Instead of using the annotation approach of the ribbon API in https://github.com/wildfly-swarm/wildfly-swarm-examples/tree/master/ribbon I use the more powerful Template API of Ribbon (https://github.com/Netflix/ribbon) to have the ability to use ResponseValidators that can validate a io.reactivex.netty.protocol.http.client.HttpClientResponse eg. for status code checks.

      Therefore I replaced the following line in org.wildfly.swarm.examples.netflix.ribbon.events.EventsResource

      //LINE 50    
      Observable<ByteBuf> obs = this.time.currentTime().observe();
      

      with

      HttpResourceGroup httpResourceGroup = Ribbon.createHttpResourceGroup("time",
              ClientOptions.create().withMaxAutoRetriesNextServer(3));
      Observable<ByteBuf> obs = httpResourceGroup.newTemplateBuilder("currentTime", ByteBuf.class)
                      .withMethod("GET")
                      .withUriTemplate("/")
                      .withResponseValidator(new HttpResponseValidator() {
      
                          @Override
                          public void validate(HttpClientResponse<ByteBuf> response)
                                  throws UnsuccessfulResponseException, ServerError {
                              System.out.println("VALIDATE");
                              System.out.println(response);
                          }
                      })
                      .build()
                      .requestBuilder()
                      .build()
                      .observe();
      

      The problem is that a class cast exception is thrown in the ResponseValidator:

      Caused by: java.lang.ClassCastException: io.reactivex.netty.protocol.http.client.HttpClientResponse cannot be cast to io
      .reactivex.netty.protocol.http.client.HttpClientResponse
      

      Full trace:

      18:48:47,319 ERROR [stderr] (rxnetty-nio-eventloop-3-1) ERROR: currentTime failed and no fallback available.
      
      18:48:47,321 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (rxnetty-nio-eventloop-3-1) RESTEASY002025: Unknown exceptio
      n while executing GET /: com.netflix.hystrix.exception.HystrixRuntimeException: currentTime failed and no fallback avail
      able.
              at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:764)
              at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:751)
              at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.jav
      a:77)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1392)
              at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1282)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9302)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9292)
              at rx.Observable$1.call(Observable.java:144)
              at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
              at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
              at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
              at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.ClassCastException: io.reactivex.netty.protocol.http.client.HttpClientResponse cannot be cast to io
      .reactivex.netty.protocol.http.client.HttpClientResponse
              at org.wildfly.swarm.examples.netflix.ribbon.events.EventsResource$MyValidator.validate(EventsResource.java:1)
              at com.netflix.ribbon.http.HttpResourceObservableCommand$1.call(HttpResourceObservableCommand.java:86)
              at com.netflix.ribbon.http.HttpResourceObservableCommand$1.call(HttpResourceObservableCommand.java:82)
              at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
              ... 68 more
      Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: io.reactivex.netty.protocol.
      http.client.HttpClientResponse.class
              at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:101)
              at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:58)
              ... 68 more
      
      18:48:47,327 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (rxnetty-nio-eventloop-3-1) RESTEASY002020: Unhandled asynch
      ronous exception, sending back 500: org.jboss.resteasy.spi.UnhandledException: com.netflix.hystrix.exception.HystrixRunt
      imeException: currentTime failed and no fallback available.
              at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:247)
              at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:168)
              at org.jboss.resteasy.core.SynchronousDispatcher.asynchronousExceptionDelivery(SynchronousDispatcher.java:437)
              at org.jboss.resteasy.core.AbstractAsynchronousResponse.internalResume(AbstractAsynchronousResponse.java:191)
              at org.jboss.resteasy.plugins.server.servlet.Servlet3AsyncHttpRequest$Servlet3ExecutionContext$Servle3Asychronou
      sResponse.resume(Servlet3AsyncHttpRequest.java:114)
              at org.wildfly.swarm.examples.netflix.ribbon.events.EventsResource.lambda$1(EventsResource.java:100)
              at rx.Observable$33.onError(Observable.java:7370)
              at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:154)
              at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
              at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onError(SubjectSubscriptionManager.java:228)
              at rx.internal.operators.NotificationLite.accept(NotificationLite.java:147)
              at rx.subjects.ReplaySubject$UnboundedReplayState.accept(ReplaySubject.java:466)
              at rx.subjects.ReplaySubject$UnboundedReplayState.replayObserverFromIndex(ReplaySubject.java:515)
              at rx.subjects.ReplaySubject$UnboundedReplayState.replayObserver(ReplaySubject.java:503)
              at rx.subjects.ReplaySubject.caughtUp(ReplaySubject.java:423)
              at rx.subjects.ReplaySubject.onError(ReplaySubject.java:383)
              at rx.Observable$35.onError(Observable.java:7463)
              at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:154)
              at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
              at rx.internal.operators.OperatorMap$1.onError(OperatorMap.java:49)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9302)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9292)
              at rx.Observable.unsafeSubscribe(Observable.java:7495)
              at com.netflix.hystrix.AbstractCommand$CommandHookApplication$1.onError(AbstractCommand.java:1220)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at com.netflix.hystrix.AbstractCommand$DeprecatedOnCompleteWithValueHookApplication$1.onError(AbstractCommand.ja
      va:1312)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9302)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9292)
              at rx.Observable.unsafeSubscribe(Observable.java:7495)
              at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.jav
      a:78)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1392)
              at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1282)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9302)
              at rx.Observable$ThrowObservable$1.call(Observable.java:9292)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable$1.call(Observable.java:144)
              at rx.Observable$1.call(Observable.java:136)
              at rx.Observable.unsafeSubscribe(Observable.java:7495)
              at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.jav
      a:78)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$3.onError(AbstractCommand.java:925)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
              at com.netflix.hystrix.AbstractCommand$DeprecatedOnRunHookApplication$1.onError(AbstractCommand.java:1351)
              at com.netflix.hystrix.AbstractCommand$ExecutionHookApplication$1.onError(AbstractCommand.java:1251)
              at rx.internal.operators.OperatorMerge$MergeSubscriber.innerError(OperatorMerge.java:457)
              at rx.internal.operators.OperatorMerge$MergeSubscriber.onError(OperatorMerge.java:432)
              at rx.internal.operators.OperatorMap$1.onError(OperatorMap.java:49)
              at rx.internal.operators.OperatorMap$1.onError(OperatorMap.java:49)
              at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:58)
              at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onNext(OperatorOnErrorResumeNextViaFunction.java
      :89)
              at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber$1$1.onNext(OperatorRetryWithPredicate.java:
      113)
              at rx.observers.SerializedObserver.onNext(SerializedObserver.java:159)
              at rx.observers.SerializedSubscriber.onNext(SerializedSubscriber.java:95)
              at rx.internal.operators.OperatorConcat$ConcatInnerSubscriber.onNext(OperatorConcat.java:210)
              at rx.observers.SerializedObserver.onNext(SerializedObserver.java:159)
              at rx.observers.SerializedSubscriber.onNext(SerializedSubscriber.java:95)
              at rx.internal.operators.OperatorConcat$ConcatInnerSubscriber.onNext(OperatorConcat.java:210)
              at rx.internal.operators.OperatorDoOnEach$1.onNext(OperatorDoOnEach.java:84)
              at rx.observers.SerializedObserver.onNext(SerializedObserver.java:159)
              at rx.observers.SerializedSubscriber.onNext(SerializedSubscriber.java:95)
              at rx.internal.operators.OperatorConcat$ConcatInnerSubscriber.onNext(OperatorConcat.java:210)
              at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:43)
              at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:32)
              at rx.Observable.unsafeSubscribe(Observable.java:7495)
              at rx.internal.operators.OperatorConcat$ConcatSubscriber.subscribeNext(OperatorConcat.java:176)
              at rx.internal.operators.OperatorConcat$ConcatSubscriber.onNext(OperatorConcat.java:141)
              at rx.internal.operators.OperatorConcat$ConcatSubscriber.onNext(OperatorConcat.java:78)
              at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
              at rx.internal.operators.OperatorFinally$1.onNext(OperatorFinally.java:45)
              at rx.internal.operators.OperatorTake$1.onNext(OperatorTake.java:67)
              at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:130)
              at rx.internal.operators.OperatorDoOnEach$1.onNext(OperatorDoOnEach.java:84)
              at rx.internal.operators.OperatorDoOnEach$1.onNext(OperatorDoOnEach.java:84)
              at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
              at rx.subjects.PublishSubject.onNext(PublishSubject.java:114)
              at rx.observers.SerializedObserver.onNext(SerializedObserver.java:159)
              at rx.subjects.SerializedSubject.onNext(SerializedSubject.java:64)
              at io.reactivex.netty.pipeline.ObservableAdapter.channelRead(ObservableAdapter.java:40)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
              at io.reactivex.netty.protocol.http.client.ClientRequestResponseConverter.channelRead(ClientRequestResponseConve
      rter.java:130)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
              at io.reactivex.netty.contexts.AbstractClientContextHandler.channelRead(AbstractClientContextHandler.java:63) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
              at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:240)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
              at io.reactivex.netty.metrics.BytesInspector.channelRead(BytesInspector.java:59)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.reactivex.netty.pipeline.InternalReadTimeoutHandler.channelRead(InternalReadTimeoutHandler.java:108)
              at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
              at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
              at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
              at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
              at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
              at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
              at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
              at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
              at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
              at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: currentTime failed and no fallback available.
              at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:764)
              at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:751)
              at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.jav
      a:77)
              ... 105 more
      Caused by: java.lang.ClassCastException: io.reactivex.netty.protocol.http.client.HttpClientResponse cannot be cast to io
      .reactivex.netty.protocol.http.client.HttpClientResponse
              at org.wildfly.swarm.examples.netflix.ribbon.events.EventsResource$MyValidator.validate(EventsResource.java:1)
              at com.netflix.ribbon.http.HttpResourceObservableCommand$1.call(HttpResourceObservableCommand.java:86)
              at com.netflix.ribbon.http.HttpResourceObservableCommand$1.call(HttpResourceObservableCommand.java:82)
              at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
              ... 68 more
      Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: io.reactivex.netty.protocol.
      http.client.HttpClientResponse.class
              at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:101)
              at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:58)
              ... 68 more
      
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                kenfinni Ken Finnigan
                Reporter:
                sialcasa Alexander Casall
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: