Hello, I'm trying to run the fraud detection examp...
# troubleshooting
s
Hello, I'm trying to run the fraud detection example in https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/try-flink/datastream, but I'm getting
NoClassDefFoundError
Here's what I did: 1. Run the Maven project
archetype:generate
command. 2.
cd frauddetection
3. Run
mvn clean package
4. Run
java -jar target/frauddetection-0.1.jar
What I get:
Copy code
Error: Unable to initialize main class spendreport.FraudDetectionJob
Caused by: java.lang.NoClassDefFoundError: org/apache/flink/streaming/api/functions/source/SourceFunction
Note that I did not touch any of the project files. I created a Slack account to post this after scouring the internet for two hours and no solution. Any help would be appreciated.
d
A couple of things to check: 1. The playgrounds haven't been updated for 1.17, so maybe try with Flink 1.16 if you haven't already. 2. If I recall correctly, that particular playground isn't mean to work out-of-the-box. I think you have to supply some missing code (which is included in the docs).
s
NoClassDefFoundError
I think the problem is related to flink dependency scopes being set to "provided",
Copy code
<!-- Apache Flink dependencies -->
		<!-- These dependencies are provided, because they should not be packaged into the JAR file. -->
Why shouldn't they be package into the JAR? I could not find an explanation anywhere. I assume that they would be necessary for the program to run. Am I building it wrong? I'm just doing
mvn package
;
java -jar myjar
. I could get the program to run when I set the dependency scopes to "compile" but I had to remove the exclusions for log4j dependencies in the shade config. How am I supposed to build a flink program? I can't fathom that the way to build one is change the maven config in an undocumented way for even the "quickstart" skeleton.
d
If you are trying to run the application in an IDE (e.g., IntelliJ), you'll need to modify the run configuration to include dependencies with the provided scope.