From 4e5d1a4a7353dd82e830d4db6319fc1348f30870 Mon Sep 17 00:00:00 2001 From: Andy Stark Date: Fri, 30 Oct 2026 16:46:07 +0000 Subject: [PATCH] DOC-7228 Fix the Lettuce use-case dependency recipes and pin 7.9.0 Nine use-case pages told readers to build the demos from hand-collected jars. Four of them (leaderboard, rate-limiter, session-store, time-series-dashboard) gave a javac and java command with only lettuce-core on the classpath, which never worked: javac passes, then the server dies with NoClassDefFoundError for io.netty.channel.ChannelHandler, reproduced on the page's own 6.7.1 recipe in a clean directory. Prefetch-cache and streaming listed ten jars at Netty 4.1.113, Reactor 3.6.6 and Lettuce 6.5.0, and cache-aside, job-queue and pub-sub assumed a lib/ directory without saying how to fill it. Lettuce 7.9.0 resolves to fifteen runtime jars: eight Netty 4.2.17 modules (the codec jars were split, so netty-codec is now netty-codec-base and netty-codec-dns), reactor-core 3.8.7, reactive-streams, jspecify, redis-authx-core and slf4j-api. Rather than hand-list those and let them drift again, every page now has the same step: write a minimal pom.xml that depends on lettuce-core 7.9.0.RELEASE and run mvn dependency:copy-dependencies into lib/, then javac and java use -cp 'lib/*'. pub-sub already recommended Maven; the others now match it. The Maven and Gradle snippets on job-queue, leaderboard, rate-limiter, session-store and time-series-dashboard moved from 6.7.1 to 7.9.0, and the leaderboard DemoServer comment that repeated the old jar command was updated. I ran each page's dependency, javac and java commands literally, extracted from the page, in a fresh directory against Redis 8.10.2, then drove each server with requests that write to and read from Redis (cache read miss then hit, jobs enqueued and completed by workers, scores landing in the sorted set, a prefetched record served as a hit, pub/sub messages delivered, the token bucket allowing then denying, a login cookie that reads the session back, stream entries produced, the time series snapshot). Every demo passed. Streaming's /state takes 6 to 10 seconds because the consumer workers hold the shared connection in blocking XREADGROUP; a control run on Lettuce 6.5.0 took the same 10.4 seconds, so it is not a 7.9.0 regression. Learned: a one-jar javac and java recipe compiles but cannot run, and Lettuce 7.9.0 needs fifteen runtime jars that dependency:copy-dependencies collects exactly Constraint: these pages must run with -cp 'lib/*' from a lib/ filled by Maven, not a hand-written jar list, so the Netty and Reactor versions track whatever lettuce-core resolves Directive: do not hand-list Netty or Reactor jar versions in these pages again; change the lettuce-core version in the pom.xml snippet and nothing else Gaps: the commands were run with the source files copied from this branch instead of curl-ed from main, readers need Maven installed, and the older "Lettuce 6.1 or later" prerequisite floors were not re-verified Ticket: DOC-7228 Co-Authored-By: Claude Sonnet 5.5 --- .../cache-aside/java-lettuce/_index.md | 25 +++++++++++++++ .../job-queue/java-lettuce/_index.md | 29 +++++++++++++++-- .../leaderboard/java-lettuce/DemoServer.java | 4 +-- .../leaderboard/java-lettuce/_index.md | 31 ++++++++++++++++--- .../prefetch-cache/java-lettuce/_index.md | 29 ++++++++++------- .../use-cases/pub-sub/java-lettuce/_index.md | 25 +++++++++++---- .../rate-limiter/java-lettuce/_index.md | 31 ++++++++++++++++--- .../session-store/java-lettuce/_index.md | 31 ++++++++++++++++--- .../streaming/java-lettuce/_index.md | 29 ++++++++++------- .../java-lettuce/_index.md | 31 ++++++++++++++++--- 10 files changed, 214 insertions(+), 51 deletions(-) diff --git a/content/develop/use-cases/cache-aside/java-lettuce/_index.md b/content/develop/use-cases/cache-aside/java-lettuce/_index.md index f8cf5d96b4..ce6a5c58a6 100644 --- a/content/develop/use-cases/cache-aside/java-lettuce/_index.md +++ b/content/develop/use-cases/cache-aside/java-lettuce/_index.md @@ -275,6 +275,31 @@ If your Redis server is running elsewhere, start the demo with `--redis-host` an ## Running the demo +### Get Lettuce and its dependencies + +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: + +```bash +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib +``` + +### Start the demo server + A local demo server is included to show the cache-aside layer in action ([source](DemoServer.java)): diff --git a/content/develop/use-cases/job-queue/java-lettuce/_index.md b/content/develop/use-cases/job-queue/java-lettuce/_index.md index e9c57f80ed..1d2b1667b9 100644 --- a/content/develop/use-cases/job-queue/java-lettuce/_index.md +++ b/content/develop/use-cases/job-queue/java-lettuce/_index.md @@ -296,14 +296,14 @@ Add Lettuce to your project: io.lettuce lettuce-core - 6.7.1.RELEASE + 7.9.0.RELEASE ``` * If you use **Gradle**: ```groovy - implementation 'io.lettuce:lettuce-core:6.7.1.RELEASE' + implementation 'io.lettuce:lettuce-core:7.9.0.RELEASE' ``` ## Running the demo @@ -321,9 +321,32 @@ curl -O $BASE/WorkerPool.java curl -O $BASE/DemoServer.java ``` +### Get Lettuce and its dependencies + +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: + +```bash +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib +``` + ### Start the demo server -From that directory, compile the sources and run the server. With the Lettuce + netty + reactor jars staged in a local `lib/` directory: +From that directory, compile the sources and run the server: ```bash javac -cp "lib/*" -d build RedisJobQueue.java JobWorker.java WorkerPool.java DemoServer.java diff --git a/content/develop/use-cases/leaderboard/java-lettuce/DemoServer.java b/content/develop/use-cases/leaderboard/java-lettuce/DemoServer.java index 8029861f23..104127f10d 100644 --- a/content/develop/use-cases/leaderboard/java-lettuce/DemoServer.java +++ b/content/develop/use-cases/leaderboard/java-lettuce/DemoServer.java @@ -20,8 +20,8 @@ * Redis leaderboard demo server using the async Lettuce implementation. * * Usage: - * javac -cp lettuce-core-6.7.1.RELEASE.jar AsyncRedisLeaderboard.java ReactiveRedisLeaderboard.java DemoServer.java - * java -cp .:lettuce-core-6.7.1.RELEASE.jar DemoServer [--port PORT] [--redis-host HOST] [--redis-port PORT] + * javac -cp 'lib/*' AsyncRedisLeaderboard.java ReactiveRedisLeaderboard.java DemoServer.java + * java -cp '.:lib/*' DemoServer [--port PORT] [--redis-host HOST] [--redis-port PORT] */ public class DemoServer { diff --git a/content/develop/use-cases/leaderboard/java-lettuce/_index.md b/content/develop/use-cases/leaderboard/java-lettuce/_index.md index ca223ad406..355cf38d81 100644 --- a/content/develop/use-cases/leaderboard/java-lettuce/_index.md +++ b/content/develop/use-cases/leaderboard/java-lettuce/_index.md @@ -52,14 +52,14 @@ Add the Lettuce dependency to your project: io.lettuce lettuce-core - 6.7.1.RELEASE + 7.9.0.RELEASE ``` * If you use **Gradle**: ```groovy - implementation 'io.lettuce:lettuce-core:6.7.1.RELEASE' + implementation 'io.lettuce:lettuce-core:7.9.0.RELEASE' ``` ### Lettuce vs Jedis @@ -253,16 +253,39 @@ curl -O $BASE/ReactiveRedisLeaderboard.java curl -O $BASE/DemoServer.java ``` +### Get Lettuce and its dependencies + +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: + +```bash +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib +``` + ### Start the demo server A local demo server ([source](https://github.com/redis/docs/blob/main/content/develop/use-cases/leaderboard/java-lettuce/DemoServer.java)) is included to show the leaderboard in action: ```bash # Compile -javac -cp lettuce-core-6.7.1.RELEASE.jar AsyncRedisLeaderboard.java ReactiveRedisLeaderboard.java DemoServer.java +javac -cp 'lib/*' AsyncRedisLeaderboard.java ReactiveRedisLeaderboard.java DemoServer.java # Run the demo server -java -cp .:lettuce-core-6.7.1.RELEASE.jar DemoServer +java -cp '.:lib/*' DemoServer ``` The demo uses the async implementation for the HTTP handlers and provides an interactive web interface where you can: diff --git a/content/develop/use-cases/prefetch-cache/java-lettuce/_index.md b/content/develop/use-cases/prefetch-cache/java-lettuce/_index.md index d158bacd15..ed61f40268 100644 --- a/content/develop/use-cases/prefetch-cache/java-lettuce/_index.md +++ b/content/develop/use-cases/prefetch-cache/java-lettuce/_index.md @@ -292,20 +292,25 @@ curl -O $BASE/SyncWorker.java curl -O $BASE/DemoServer.java ``` -You also need Lettuce and its runtime dependencies on your classpath. The simplest way is to download them into a local `lib/` directory: +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: ```bash -mkdir lib && cd lib -LETTUCE=https://repo1.maven.org/maven2/io/lettuce/lettuce-core/6.5.0.RELEASE -curl -O $LETTUCE/lettuce-core-6.5.0.RELEASE.jar -NETTY=https://repo1.maven.org/maven2/io/netty -for ARTIFACT in netty-buffer netty-codec netty-common netty-handler \ - netty-resolver netty-transport netty-transport-native-unix-common; do - curl -O "$NETTY/$ARTIFACT/4.1.113.Final/$ARTIFACT-4.1.113.Final.jar" -done -curl -O https://repo1.maven.org/maven2/io/projectreactor/reactor-core/3.6.6/reactor-core-3.6.6.jar -curl -O https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.4/reactive-streams-1.0.4.jar -cd .. +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib ``` ### Start the demo server diff --git a/content/develop/use-cases/pub-sub/java-lettuce/_index.md b/content/develop/use-cases/pub-sub/java-lettuce/_index.md index c570e2b238..487dba3066 100644 --- a/content/develop/use-cases/pub-sub/java-lettuce/_index.md +++ b/content/develop/use-cases/pub-sub/java-lettuce/_index.md @@ -254,13 +254,26 @@ curl -O $BASE/RedisPubSubHub.java curl -O $BASE/DemoServer.java ``` -You also need a `lib/` directory containing the Lettuce client and its runtime dependencies — at minimum: +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: -* `lettuce-core-6.x.jar` -* `netty-buffer-4.1.x.jar`, `netty-codec-4.1.x.jar`, `netty-common-4.1.x.jar`, `netty-handler-4.1.x.jar`, `netty-resolver-4.1.x.jar`, `netty-transport-4.1.x.jar`, `netty-transport-native-unix-common-4.1.x.jar` -* `reactor-core-3.x.jar`, `reactive-streams-1.0.x.jar` - -The simplest way to collect them is with Maven. Create a minimal `pom.xml` declaring `io.lettuce:lettuce-core` as the only dependency, then run `mvn dependency:copy-dependencies -DoutputDirectory=lib`. +```bash +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib +``` ### Start the demo server diff --git a/content/develop/use-cases/rate-limiter/java-lettuce/_index.md b/content/develop/use-cases/rate-limiter/java-lettuce/_index.md index e825508854..038b714c84 100644 --- a/content/develop/use-cases/rate-limiter/java-lettuce/_index.md +++ b/content/develop/use-cases/rate-limiter/java-lettuce/_index.md @@ -125,14 +125,14 @@ Add the Lettuce dependency to your project: io.lettuce lettuce-core - 6.7.1.RELEASE + 7.9.0.RELEASE ``` * If you use **Gradle**: ```groovy - implementation 'io.lettuce:lettuce-core:6.7.1.RELEASE' + implementation 'io.lettuce:lettuce-core:7.9.0.RELEASE' ``` ### Lettuce vs Jedis @@ -308,6 +308,29 @@ curl -O $BASE/ReactiveTokenBucket.java curl -O $BASE/DemoServer.java ``` +### Get Lettuce and its dependencies + +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: + +```bash +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib +``` + ### Start the demo server A demonstration HTTP server is included to show the rate limiter in action @@ -315,10 +338,10 @@ A demonstration HTTP server is included to show the rate limiter in action ```bash # Compile -javac -cp lettuce-core-6.7.1.RELEASE.jar TokenBucket.java DemoServer.java +javac -cp 'lib/*' TokenBucket.java DemoServer.java # Run the demo server -java -cp .:lettuce-core-6.7.1.RELEASE.jar DemoServer +java -cp '.:lib/*' DemoServer ``` The demo provides an interactive web interface where you can: diff --git a/content/develop/use-cases/session-store/java-lettuce/_index.md b/content/develop/use-cases/session-store/java-lettuce/_index.md index b95f5af854..55a3d60e0a 100644 --- a/content/develop/use-cases/session-store/java-lettuce/_index.md +++ b/content/develop/use-cases/session-store/java-lettuce/_index.md @@ -187,14 +187,14 @@ Add Lettuce to your project: io.lettuce lettuce-core - 6.7.1.RELEASE + 7.9.0.RELEASE ``` * If you use **Gradle**: ```groovy - implementation 'io.lettuce:lettuce-core:6.7.1.RELEASE' + implementation 'io.lettuce:lettuce-core:7.9.0.RELEASE' ``` ## Running the demo @@ -211,14 +211,37 @@ curl -O $BASE/ReactiveSessionStore.java curl -O $BASE/DemoServer.java ``` +### Get Lettuce and its dependencies + +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: + +```bash +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib +``` + ### Start the demo server A local demo server is included to show the session store in action ([source](https://github.com/redis/docs/blob/main/content/develop/use-cases/session-store/java-lettuce/DemoServer.java)): ```bash -javac -cp lettuce-core-6.7.1.RELEASE.jar AsyncSessionStore.java DemoServer.java -java -cp .:lettuce-core-6.7.1.RELEASE.jar DemoServer +javac -cp 'lib/*' AsyncSessionStore.java DemoServer.java +java -cp '.:lib/*' DemoServer ``` The demo uses the async Lettuce API and exposes a small interactive page where you can: diff --git a/content/develop/use-cases/streaming/java-lettuce/_index.md b/content/develop/use-cases/streaming/java-lettuce/_index.md index 090d2d8f68..083bfa5737 100644 --- a/content/develop/use-cases/streaming/java-lettuce/_index.md +++ b/content/develop/use-cases/streaming/java-lettuce/_index.md @@ -338,20 +338,25 @@ curl -O $BASE/ConsumerWorker.java curl -O $BASE/DemoServer.java ``` -You also need Lettuce and its runtime dependencies on your classpath. The simplest way is to download them into a local `lib/` directory: +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: ```bash -mkdir lib && cd lib -LETTUCE=https://repo1.maven.org/maven2/io/lettuce/lettuce-core/6.5.0.RELEASE -curl -O $LETTUCE/lettuce-core-6.5.0.RELEASE.jar -NETTY=https://repo1.maven.org/maven2/io/netty -for ARTIFACT in netty-buffer netty-codec netty-common netty-handler \ - netty-resolver netty-transport netty-transport-native-unix-common; do - curl -O "$NETTY/$ARTIFACT/4.1.113.Final/$ARTIFACT-4.1.113.Final.jar" -done -curl -O https://repo1.maven.org/maven2/io/projectreactor/reactor-core/3.6.6/reactor-core-3.6.6.jar -curl -O https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.4/reactive-streams-1.0.4.jar -cd .. +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib ``` ### Start the demo server diff --git a/content/develop/use-cases/time-series-dashboard/java-lettuce/_index.md b/content/develop/use-cases/time-series-dashboard/java-lettuce/_index.md index f99ed71ebd..14710a4d50 100644 --- a/content/develop/use-cases/time-series-dashboard/java-lettuce/_index.md +++ b/content/develop/use-cases/time-series-dashboard/java-lettuce/_index.md @@ -154,7 +154,7 @@ If you use Maven: io.lettuce lettuce-core - 6.7.1.RELEASE + 7.9.0.RELEASE ``` @@ -173,19 +173,42 @@ curl -O $BASE/ReactiveRedisTimeSeriesStore.java curl -O $BASE/DemoServer.java ``` +### Get Lettuce and its dependencies + +Lettuce needs Netty, Reactor and a few other jars at runtime, and `javac` and `java` need them on the classpath. The simplest way to collect them is with Maven. In the demo directory, create a minimal `pom.xml`, then copy its dependencies into a local `lib/` directory: + +```bash +cat > pom.xml <<'EOF' + + 4.0.0 + demo + demo + 1 + + + io.lettuce + lettuce-core + 7.9.0.RELEASE + + + +EOF +mvn -q dependency:copy-dependencies -DoutputDirectory=lib +``` + ### Start the demo server Compile and run the demo: ```bash -javac -cp lettuce-core-6.7.1.RELEASE.jar:reactor-core-3.6.6.jar:reactive-streams-1.0.4.jar SensorSimulator.java AsyncRedisTimeSeriesStore.java ReactiveRedisTimeSeriesStore.java DemoServer.java -java -cp .:lettuce-core-6.7.1.RELEASE.jar:reactor-core-3.6.6.jar:reactive-streams-1.0.4.jar DemoServer +javac -cp 'lib/*' SensorSimulator.java AsyncRedisTimeSeriesStore.java ReactiveRedisTimeSeriesStore.java DemoServer.java +java -cp '.:lib/*' DemoServer ``` The server accepts optional flags if your Redis instance is not on the default host and port: ```bash -java -cp .:lettuce-core-6.7.1.RELEASE.jar:reactor-core-3.6.6.jar:reactive-streams-1.0.4.jar DemoServer --redis-host 127.0.0.1 --redis-port 6379 --port 8080 +java -cp '.:lib/*' DemoServer --redis-host 127.0.0.1 --redis-port 6379 --port 8080 ``` After starting the server, visit `http://localhost:8080`.