How to change the default Cloud Composer Java version
Stay organized with collections
Save and categorize content based on your preferences.
Problem
You are trying to use Cloud Composer to run Java 11 JARs, but Airflow tasks only support Java 8. How can you change the default Cloud Composer Java to version 11 and above?
The following log is obtained when running the Java 11 compiled JAR:
Error: A JNI error has occurred, please check your installation and try again\nException in thread "main" java.lang.UnsupportedClassVersionError: <REDACTED> has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Environment
Solution
- Use the DataflowTemplateOperator instead of the DataFlowJavaOperator.
- Use KubernetesPodOperator and create a Docker image with Google Cloud and Java 11.
Note: The
DataFlowJavaOperator requires Java to be locally installed in order to prepare artifacts, while with
DataflowTemplateOperator,
Dataflow templates guarantee that the version of JARs is exactly the same between executions.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-12 UTC."],[],[]]