title: Exception threw in IntegrationTest: RedisCommandExecutionException: ERR no such key
body: <p>Currently I am trying to convert <a href="https://github.com/hantsy/spring-microservice-sample" rel="nofollow noreferrer">microservice sample</a> to Spring 5 reactive stack, but when create a simple auth service with Redis(store sessions via Spring Data Redis) and Cassandra(user data via Spring Data Cassandra).</p>
  
  <p>The complete source of the new reactive stack is <a href="https://github.com/hantsy/spring-reactive-microservice-sample" rel="nofollow noreferrer">here</a> (WIP).</p>
  
  <p><a href="https://github.com/hantsy/spring-reactive-microservice-sample/blob/master/auth-service/src/test/java/com/example/authservice/AuthServiceApplicationTests.java" rel="nofollow noreferrer">AuthServiceApplicationTests</a> works well when ran Spring Boot Test in a Mock env.</p>
  
  <p>But <a href="https://github.com/hantsy/spring-reactive-microservice-sample/blob/master/auth-service/src/test/java/com/example/authservice/IntegrationTests.java" rel="nofollow noreferrer">IntegrationTests</a> failed with exceptions when ran <code>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)</code>.</p>
  
  <p>The exception info looks:</p>
  
  <pre><code>org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR no such key
  at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:54) ~[spring-data-redis-2.0.2.RELEASE.jar:2.0.2.RELEASE]
  at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41) ~[spring-data-redis-2.0.2.RELEASE.jar:2.0.2.RELEASE]
  at org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection.lambda$translateException$0(LettuceReactiveRedisConnection.java:267) ~[spring-data-redis-2.0.2.RELEASE.jar:2.0.2.RELEASE]
  at reactor.core.publisher.Flux.lambda$onErrorMap$23(Flux.java:5170) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
  at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:88) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
  at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onError(MonoFlatMapMany.java:243) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
  at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:120) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
  at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:120) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
  at reactor.core.publisher.MonoNext$NextSubscriber.onError(MonoNext.java:87) ~[reactor-core-3.1.2.RELEASE.jar:3.1.2.RELEASE]
  at io.lettuce.core.RedisPublisher$State.onError(RedisPublisher.java:655) ~[lettuce-core-5.0.1.RELEASE.jar:na]
  at io.lettuce.core.RedisPublisher$RedisSubscription.onError(RedisPublisher.java:313) ~[lettuce-core-5.0.1.RELEASE.jar:na]
  at io.lettuce.core.RedisPublisher$SubscriptionCommand.onError(RedisPublisher.java:767) ~[lettuce-core-5.0.1.RELEASE.jar:na]
  at io.lettuce.core.RedisPublisher$SubscriptionCommand.complete(RedisPublisher.java:703) ~[lettuce-core-5.0.1.RELEASE.jar:na]
  at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:558) ~[lettuce-core-5.0.1.RELEASE.jar:na]
  at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:511) ~[lettuce-core-5.0.1.RELEASE.jar:na]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:138) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) ~[netty-transport-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) ~[netty-common-4.1.17.Final.jar:4.1.17.Final]
  at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138) ~[netty-common-4.1.17.Final.jar:4.1.17.Final]
  at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_152]
  Caused by: io.lettuce.core.RedisCommandExecutionException: ERR no such key
  ... 26 common frames omitted
  </code></pre>
  
  <p>I used the similar solutions to taste new reactive features in Spring Session 2 and Spring Security 5 in <a href="https://github.com/hantsy/spring-reactive-sample/tree/master/session-header" rel="nofollow noreferrer">this simple sample</a>, it worked. The difference is in this sample I used <code>MapReactiveWebSessionRepository</code> instead of the redis specific ReactiveWebSessionRepository.</p>
  
  <p><strong>Updated</strong>, updated Spring Session to 2.0.0.RELEASE in my codes, it works as expected.</p>