Hi Team, I am using Flink 1.18.1 and Scala 3.4.2(...
# troubleshooting
a
Hi Team, I am using Flink 1.18.1 and Scala 3.4.2(and Java 17) I have added Flink-streaming-java dependency with scope compile and version kept 1.18.1 but I am getting: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/runtime/state/CheckpointStorage at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.init(StreamExecutionEnvironment.java:189) at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.init(StreamExecutionEnvironment.java:265) at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.init(StreamExecutionEnvironment.java:253) at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.init(LocalStreamEnvironment.java:51) at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.createLocalEnvironment(StreamExecutionEnvironment.java:2501) at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.lambda$getExecutionEnvironment$20(StreamExecutionEnvironment.java:2443) at java.base/java.util.Optional.orElseGet(Optional.java:364) at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getExecutionEnvironment(StreamExecutionEnvironment.java:2443) at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getExecutionEnvironment(StreamExecutionEnvironment.java:2425)
Copy code
at com.Proj1.flinkPgm.configs.FlinkExecutionEnvironment$.initialize(FlinkExecutionEnvironment.scala:29)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.runtime.state.CheckpointStorage
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
Please suggest!!
i
This one sounds like required class is missing from the classpath somehow.
a
maven build was successful though. did nt get what is wrong here
d
Ok so CheckpointStorage not found. CheckpointStorage, a part of Flink’s runtime, is not found at runtime. Since your Maven build was successful, its probably due to how you’re running your compiled Scala program rather than from the build configuration itself.
So you can try a few things: 1. Check that you are using the right scope. Compile scope should work and it should look something like the following
Copy code
<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-streaming-java_2.12</artifactId>
    <!-- ensure the version matches your Flink version -->
   <version>1.18.1</version>
</dependency>
2. Try running your Scala application directly from Maven using exec:java goal. This will automatically set up the classpath based on your pom.xml. If you don’t have this plugin yet, add it to your pom.xml:
Copy code
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <mainClass>com.Proj1.flinkPgm.YourMainClass</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>
Then, run your application with:
Copy code
mvn clean compile exec:java -Dexec.mainClass="com.Proj1.flinkPgm.YourMainClass"
Replace
Copy code
com.Proj1.flinkPgm.YourMainClass
with your main class.
If that does not work you can consider building an “uber-jar” or “fat jar,” which packages all dependencies into a single JAR file. Use the Maven Shade Plugin for this.
a
Thanks Draco for suggestion this resolved my issue. I simply kept flink-runtime scope as compile
d
ok that’s great
a
Again Thank you so much 👍
d
Glad it was resolved!