【问题标题】:Unable to run Flink job when jar file is submitted, but program running otherwise in Intellij [duplicate]提交jar文件时无法运行Flink作业,但程序在Intellij中运行[重复]
【发布时间】:2017-10-26 00:59:56
【问题描述】:

我的 Flink 程序在 IntellijIdea 中运行成功,但是当我将该程序的 jar 文件作为 jar 提交时,它显示以下错误

ava.lang.RuntimeException: Could not look up the main(String[]) method from the class org.carleton.cep.monitoring.latest.MobileCEP: org/apache/flink/cep/pattern/conditions/IterativeCondition
    at org.apache.flink.client.program.PackagedProgram.hasMainMethod(PackagedProgram.java:480)
    at org.apache.flink.client.program.PackagedProgram.<init>(PackagedProgram.java:217)
    at org.apache.flink.client.program.PackagedProgram.<init>(PackagedProgram.java:148)
    at org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.getJobGraphAndClassLoader(JarActionHandler.java:91)
    at org.apache.flink.runtime.webmonitor.handlers.JarPlanHandler.handleRequest(JarPlanHandler.java:42)
    at org.apache.flink.runtime.webmonitor.RuntimeMonitorHandler.respondAsLeader(RuntimeMonitorHandler.java:88)
    at org.apache.flink.runtime.webmonitor.RuntimeMonitorHandlerBase.channelRead0(RuntimeMonitorHandlerBase.java:84)
    at org.apache.flink.runtime.webmonitor.RuntimeMonitorHandlerBase.channelRead0(RuntimeMonitorHandlerBase.java:44)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.handler.codec.http.router.Handler.routed(Handler.java:62)
    at io.netty.handler.codec.http.router.DualAbstractHandler.channelRead0(DualAbstractHandler.java:57)
    at io.netty.handler.codec.http.router.DualAbstractHandler.channelRead0(DualAbstractHandler.java:20)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at org.apache.flink.runtime.webmonitor.HttpRequestHandler.channelRead0(HttpRequestHandler.java:105)
    at org.apache.flink.runtime.webmonitor.HttpRequestHandler.channelRead0(HttpRequestHandler.java:65)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:242)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/apache/flink/cep/pattern/conditions/IterativeCondition
    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 org.apache.flink.client.program.PackagedProgram.hasMainMethod(PackagedProgram.java:474)
    ... 34 more
Caused by: java.lang.ClassNotFoundException: org.apache.flink.cep.pattern.conditions.IterativeCondition
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 40 more

我已经处理了清单文件中的类路径,以前我也可以使用我的 jar 运行。

下面给出的模式代码似乎存在一些问题

 // detecting pattern

    Pattern<JoinedEvent, ?> pattern = Pattern.<JoinedEvent>begin("start")
            .subtype(JoinedEvent.class).
                    where(new SimpleCondition<JoinedEvent>() {
                        @Override
                        public boolean filter(JoinedEvent streamEvent) throws Exception {

                            return streamEvent.getRRInterval()>= 10 ;
                        }
                    })

            .subtype(JoinedEvent.class).where(new SimpleCondition<JoinedEvent>() {
                @Override
                public boolean filter(JoinedEvent streamEvent) throws Exception {
                    return streamEvent.getQrsInterval() >= 10 ;
                }
            } )
            .within(Time.milliseconds(WindowLength));

【问题讨论】:

标签: apache-flink flink-streaming flink-cep


【解决方案1】:

检查依赖的范围是否设置为编译而不提供。您可以在 pom.xml 中设置它,也可以转到“文件>项目结构>模块”并在右侧查看依赖项选项卡。在该选项卡中,您将看到项目的依赖项。找到 flink.cep 的依赖项(不确定它是在核心 flink 库中还是其他依赖项中),如果还没有,则将范围设置为编译。然后,正如@MikCode 在他的评论中指出的那样,运行 mvn clean install 以确保一切都已设置并重试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-12
    • 1970-01-01
    • 1970-01-01
    • 2016-02-25
    • 2021-02-08
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    相关资源
    最近更新 更多