0

I could run Harness example here

but I copied the code to another directory and use the same dependencies in pom.xml, it raised error that no routers defined

I debug and found that MyModule which extends StateFunModule was not found. Thus the class loader get no module and the router and func size is 0 and failed in validation step. (The step to check ingress, egress, router, func not size 0)

PS: I just copied all the code, thus @AutoService is also included. According to here, it should work without further configuration.


Update: Seems its statefun issue related to @AutoService

I added following code in the pom in another project (unrelated to statefun)

        <dependency>
            <groupId>com.google.auto.service</groupId>
            <artifactId>auto-service</artifactId>
            <version>1.0-rc6</version>
            <optional>true</optional>
        </dependency>

It works, the META-INF is generated.

But if using

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>statefun-flink-distribution</artifactId>
            <version>2.2-SNAPSHOT</version>
        </dependency>

The META-INF is not generated, and I found in statefun, the dependency used is actually

        <dependency>
            <groupId>com.google.auto.service</groupId>
            <artifactId>auto-service</artifactId>
            <version>1.0-rc6</version>
            <optional>true</optional>
        </dependency>

And I test this dependency, it could not generate META-INF, and I am curious that why if we directly clone the statefun repo and mvn clean package, it could work.

Litchy
  • 623
  • 7
  • 23
  • Not sure what's wrong, but maybe having another example will help. You could look at https://github.com/ververica/flink-statefun-workshop. – David Anderson Aug 31 '20 at 07:58
  • @DavidAnderson I think the example with different location and 0 code change should be executed with no difficulty, otherwise the portability of this feature seems bad. – Litchy Aug 31 '20 at 10:47
  • The problem I ran into when writing a Harness test in flink-statefun-workshop was that I had to use exactly the same version of protobuf that is used in statefun itself, but otherwise it was straightforward. That test is in https://github.com/ververica/flink-statefun-workshop/blob/master/statefun-workshop-functions/src/test/java/com/ververica/statefun/workshop/harness/RunnerTest.java. – David Anderson Aug 31 '20 at 10:59
  • @Litchy can you please validate that indeed your jar contains a META-INF/services/org.apache.flink.statefun.sdk.spi.StatefulFunctionModule and it's content points to your MyModule class?. – Igal Sep 01 '20 at 12:22
  • @Igal I think you get the point of it. In example there is correct META-INF, but after I copied it and build, this META-INF is not generated. But who control this operation, do I need extra code in addition to copy and build? – Litchy Sep 02 '20 at 02:45
  • @Litchy you can include that file manually in your src/main/resources/META-INF/services – Igal Sep 02 '20 at 10:26
  • @Igal I create the dir and write the file by myself and it works. Anyway...this is not "auto" enough... – Litchy Sep 03 '20 at 08:12

0 Answers0