ā07-23-2025 02:53 AM
Iām trying to deploy a Databricks Review App, but Iām running into the following error.
Interestingly, the same code works fine when executed from a Databricks Notebook.
Does anyone know what might be going wrong here? Could this be a bug with the Review App?
PySparkRuntimeError: [JAVA_GATEWAY_EXITED] Java gateway process exited before sending its port number.
Traceback:
File "/app/python/source_code/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
File "/app/python/source_code/.venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 590, in code_to_exec
exec(code, module.__dict__)
File "/app/python/source_code/app.py", line 18, in <module>
from raw_to_bronze_creation import r2b_main
File "/app/python/source_code/raw_to_bronze_creation.py", line 10, in <module>
spark = SparkSession.builder.appName("Check Database Existence").enableHiveSupport().getOrCreate()
File "/app/python/source_code/.venv/lib/python3.11/site-packages/pyspark/sql/session.py", line 497, in getOrCreate
sc = SparkContext.getOrCreate(sparkConf)
File "/app/python/source_code/.venv/lib/python3.11/site-packages/pyspark/context.py", line 515, in getOrCreate
SparkContext(conf=conf or SparkConf())
File "/app/python/source_code/.venv/lib/python3.11/site-packages/pyspark/context.py", line 201, in __init__
SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
File "/app/python/source_code/.venv/lib/python3.11/site-packages/pyspark/context.py", line 436, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway(conf)
File "/app/python/source_code/.venv/lib/python3.11/site-packages/pyspark/java_gateway.py", line 107, in launch_gateway
raise PySparkRuntimeError(
ā07-23-2025 03:24 AM
I recently wrote a KB article on this. Let me know if this helps!
TLDR: Databricks Apps are lightweight, container-based runtimes designed for UI rendering and light orchestration. They do not ship with an Apache Spark driver, executor, or JVM.
Any call that instantiates a SparkSession (or lower-level SparkContext) tries to start the Java gateway and fails, producing the [JAVA_GATEWAY_EXITED]
error.
Databricks Apps should delegate compute to an existing Databricks cluster or to Databricks SQL instead of attempting to create Spark locally.
ā07-23-2025 03:52 AM
Great! Thanks for the info. Iāll give it a shot with Statement Execution API.
This should unblock. Thanks again!
ā07-23-2025 02:57 AM
Hi vishxlrxghxv,
By any chance, did you attempt to create a SparkSession?
ā07-23-2025 03:03 AM
Thank you for such a quick response. Yes, I have this in my code:
spark = SparkSession.builder.appName(āSelServeBot-POCā).getOrCreate()
ā07-23-2025 03:24 AM
I recently wrote a KB article on this. Let me know if this helps!
TLDR: Databricks Apps are lightweight, container-based runtimes designed for UI rendering and light orchestration. They do not ship with an Apache Spark driver, executor, or JVM.
Any call that instantiates a SparkSession (or lower-level SparkContext) tries to start the Java gateway and fails, producing the [JAVA_GATEWAY_EXITED]
error.
Databricks Apps should delegate compute to an existing Databricks cluster or to Databricks SQL instead of attempting to create Spark locally.
ā07-23-2025 03:52 AM
Great! Thanks for the info. Iāll give it a shot with Statement Execution API.
This should unblock. Thanks again!
Passionate about hosting events and connecting people? Help us grow a vibrant local communityāsign up today to get started!
Sign Up Now