cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Generative AI
Explore discussions on generative artificial intelligence techniques and applications within the Databricks Community. Share ideas, challenges, and breakthroughs in this cutting-edge field.
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Problem with Review App

vishxlrxghxv
New Contributor III

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(

2 ACCEPTED SOLUTIONS

Accepted Solutions

Amruth_Ashok
Databricks Employee
Databricks Employee

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. 

View solution in original post

 

 

Great! Thanks for the info. I’ll give it a shot with Statement Execution API. 

This should unblock. Thanks again!

View solution in original post

4 REPLIES 4

Amruth_Ashok
Databricks Employee
Databricks Employee

Hi vishxlrxghxv,
By any chance, did you attempt to create a SparkSession?

vishxlrxghxv
New Contributor III

Thank you for such a quick response. Yes, I have this in my code:

spark = SparkSession.builder.appName(ā€œSelServeBot-POCā€).getOrCreate()

Amruth_Ashok
Databricks Employee
Databricks Employee

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. 

 

 

Great! Thanks for the info. I’ll give it a shot with Statement Execution API. 

This should unblock. Thanks again!