What Should I Do if ClassCastException Is Reported Due to Flink JAR Package Conflicts?
Symptom
An error is reported when a job is started after introducing a third-party dependency package to Flink lib.
ClassCastException: X Cannot be cast to X
Cause Analysis
The introduced third-party dependency package conflicts with the dependency package in Flink. Precisely, the classes in the third-party dependency package are incompatible, resulting in failure to instantiate certain functions.
Solution
Method 1: Remove the conflict packages from the introduced third-party JAR. This method is recommended.
Method 2: Set classloader.resolve-order to parent-first in the flink-conf.yaml configuration file. Modify Flink class loading sequence so that the dependency packages provided by Flink are preferentially loaded.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot