Spark shell 4.x — JLine Warnings on Console¶
On Apache Spark 4.x, spark-shell showing repeated console warnings such as:
The Scala REPL writes history to $HOME/.scala_history. Spark 4.x ships JLine 3, whose history path uses Files.createDirectories() before writing; with HOME=/nonexistent, that step raises AccessDeniedException. Spark 3.x paths that relied on JLine 2 often failed more quietly for the same HOME value, so the issue tends to surface after upgrading to 4.x even when the image policy is unchanged. This warning does not affect query execution or access management.
Solution¶
Two approaches are available:
- Update
log4j2.properties - Create required directory in the image
Option 1 - Update log4j2.properties¶
Add the following block to log4j2.properties (Spark 4.x) to reduce repeated JLine console noise. This affects logging only; it does not fix history persistence.
| Properties | |
|---|---|
Use the log4j2.properties file that is packaged into the custom image (see Setup).
Option 2 - Create required directory in the image¶
Create nonexistent directory, as JLine 3 expecting this to write history, Add the following to the Dockerfile
| Docker | |
|---|---|
Rebuild, push, and redeploy¶
Both log4j2.properties and Dockerfile changes are applied by building a new image and rolling it out. After saving the edits used in the image build:
- Rebuild the Docker image — Build the Docker Image in Setup.
- Push the new image to the remote registry — Push the Docker Image to the Remote HUB.
- Redeploy Kubernetes workloads so they pull the updated image — Kubernetes Deployment.
- Prev topic: Troubleshooting