数据流和Bigtable依赖项冲突

时间:2019-07-02 23:56:48

标签: java google-cloud-dataflow apache-beam bigtable

我得到的错误:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/beam/sdk/transforms/DoFn
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.beam.sdk.transforms.DoFn
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

我的pom依赖项:

<dependencies>
        <dependency>
            <groupId>com.google.cloud.bigtable</groupId>
            <artifactId>bigtable-hbase-beam</artifactId>
            <version>1.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
            <version>2.13.0</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

我认为问题出在两个依赖项上,它们使用的是不同版本的Beam sdk,因此我将beam-runners-google-cloud-dataflow-java的版本更改为2.11.0,后者使用了相同的Beam sdk版本。但是我遇到了同样的错误。

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

您如何运行管道?我猜测问题是光束罐不在您的类路径上。您或者需要使用maven exec插件来调用main(),并使用类路径上的所有maven依赖项,或者需要使用诸如maven shade插件或maven程序集插件之类的文件来创建胖子。请在此处查看有关如何使用maven exec插件运行管道的示例: https://github.com/GoogleCloudPlatform/cloud-bigtable-examples/blob/a017a237fa8dae764451a658150190743c1b4127/java/dataflow-connector-examples/pom.xml#L146-L161