Search code examples
javaapache-flinkupgradeclassloader

Class loading issue when running tests after flink upgrade to 1.19.1 from 1.15.2


When the flink version upgraded to 1.19.1 from 1.15.2. there is a test execution issue. We are using powermock to mock the classes in tests java version 1.8 power mock 2.0.2

The Error is

org.apache.flink.util.FlinkException: Failed to execute job 'Flink Streaming Job'. at flightRebooking.BoundLogicE2ETest.endToEndTest(E2ETest.java:93) Caused by: java.lang.RuntimeException: org.apache.flink.runtime.client.JobInitializationException: Could not start the JobMaster. Caused by: org.apache.flink.runtime.client.JobInitializationException: Could not start the JobMaster. Caused by: java.util.concurrent.CompletionException: java.lang.ClassCastException: org.apache.flink.api.common.ExecutionConfig cannot be cast to org.apache.flink.api.common.ExecutionConfig Caused by: java.lang.ClassCastException: org.apache.flink.api.common.ExecutionConfig cannot be cast to org.apache.flink.api.common.ExecutionConfig

enter image description here enter image description here enter image description here


Solution

  • It appears that Flink will have classloading issues if you introduce Powermock into your testing configuration. Take a look at this posted issue Class loading issues when using Powermock. Flink provides a good test harness and discusses what to do to mock out objects. Please check out their unit test guide.