ConanLord opened a new issue, #48622:
URL: https://github.com/apache/airflow/issues/48622

   ### Apache Airflow version
   
   2.10.5
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   Hi,
   
   I use Apache Airflow 2.10.5 to run a task implemented in Java. This task is 
implemented by a `PythonOperator` that calls a Java method by using JPype.
   The Java method performs `System.out.println`.
   Unfortunately, these traces do not appear in Airflow logs (nor in the UI), 
although the traces from Python code do appear.
   
   What is strange is that the expected trace from `System.out.println` (i.e. 
_"INFO - Java code JPypeTest.call invoked !!!!!!"_) can be seen in the console 
of the airflow scheduler !
   
   Does anyone have solved this kind of issue ?
   
   Here is my DAG :
   ```
   from datetime import datetime, timedelta
   from airflow.models.dag import DAG
   from airflow.operators.python import PythonOperator
   import jpype
   
   
   def test_jpype():
   
       print("Start JVM")
       jpype.startJVM()
   
       print("Load JPypeTest Java class")
       JPypeTest = jpype.JClass("JPypeTest")
       print("Instanciate JPypeTest Java class")
       jpype_test = JPypeTest()
       print("Invoke method 'call' of JPypeTest Java class")
       jpype_test.call()
   
       print("Shutdown JVM")
       jpype.shutdownJVM()
   
       print("Done.")
   
   with DAG(
       "test_jpype",
       default_args={
           "depends_on_past": False,
           "email": ["[email protected]"],
           "email_on_failure": False,
           "email_on_retry": False,
           "retries": 0,
       },
       description="Run a task that calls Java code with JPype",
       schedule=None,
       catchup=False,
       tags=["test_jpype"],
   ) as dag:
   
       task_test_jpype = PythonOperator(
           task_id="test_jpype",
           python_callable=test_jpype,
       )
   
       task_test_jpype
   ```
   and here is my Java class :
   ```
   public class JPypeTest
   {
       public synchronized void call()
       {
           System.out.println("INFO - Java code JPypeTest.call invoked !!!!!!");
           System.out.flush();
       }
   }
   ```
   
   Here are the traces found in the log file and the UI :
   ```
   [2025-04-01T13:44:19.734+0200] {logging_mixin.py:190} INFO - Task instance 
is in running state
   [2025-04-01T13:44:19.735+0200] {logging_mixin.py:190} INFO -  Previous state 
of the Task instance: queued
   [2025-04-01T13:44:19.735+0200] {logging_mixin.py:190} INFO - Current task 
name:test_jpype state:running start_date:2025-04-01 11:44:19.604270+00:00
   [2025-04-01T13:44:19.735+0200] {logging_mixin.py:190} INFO - Dag 
name:test_jpype and current dag run status:running
   [2025-04-01T13:44:19.735+0200] {taskinstance.py:732} INFO - ::endgroup::
   [2025-04-01T13:44:19.735+0200] {logging_mixin.py:190} INFO - Start JVM
   [2025-04-01T13:44:19.983+0200] {logging_mixin.py:190} INFO - Load JPypeTest 
Java class
   [2025-04-01T13:44:19.983+0200] {logging_mixin.py:190} INFO - Instanciate 
JPypeTest Java class
   [2025-04-01T13:44:19.984+0200] {logging_mixin.py:190} INFO - Invoke method 
'call' of JPypeTest Java class
   [2025-04-01T13:44:19.984+0200] {logging_mixin.py:190} INFO - Shutdown JVM
   [2025-04-01T13:44:19.993+0200] {logging_mixin.py:190} INFO - Done.
   [2025-04-01T13:44:19.993+0200] {python.py:240} INFO - Done. Returned value 
was: None
   ```
   
   Many thanks.
   
   ### What you think should happen instead?
   
   I expect that the trace _"INFO - Java code JPypeTest.call invoked !!!!!!"_ 
appears in the logs (and in the UI) of the task
   
   ### How to reproduce
   
   To reproduce the problem :
   * Install jpype on your python distribution
   * Compile JPypeTest.java
   * Set the environment variable CLASSPATH to the directory containing 
JPypeTest.class
   * Run the dag given above
   
   ### Operating System
   
   Ubuntu WSL
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to