kafka到带有flink的opentsdb:java.lang.NoClassDefFoundError:无法初始化类org.apache.http.conn.ssl.SSLConnectionSocketFactory

时间:2018-10-25 05:46:00

标签: apache-kafka apache-flink opentsdb

这是我的代码:

def saveToOpenTSDB(rows: Iterator[String], url: String) {
          val requestConfig: RequestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(2000).setConnectionRequestTimeout(2000).build()
          val httpClient: CloseableHttpClient = HttpClients.createDefault() }

错误堆栈跟踪:

  
    

2018-10-25 12:40:39,323信息org.apache.flink.client.cli.CliFrontend     -------------------------------------------------- ------------------------------- 2018-10-25 12:40:39,324信息org.apache.flink.client。 CLI前端     -启动命令行客户端(版本:1.6.1,Rev:23e2636,Date:14.09.2018 @ 19:56:46 UTC)2018-10-25 12:40:39,324信息     org.apache.flink.client.cli.CliFrontend-操作系统     当前用户:root 2018-10-25 12:40:39,676信息     org.apache.flink.client.cli.CliFrontend-     当前的Hadoop / Kerberos用户:根2018-10-25 12:40:39,676信息     org.apache.flink.client.cli.CliFrontend-JVM:     Java HotSpot(TM)64位服务器VM-Oracle Corporation-     1.8 / 25.172-b11 2018-10-25 12:40:39,676信息org.apache.flink.client.cli.CliFrontend-     最大堆大小:7136 MiBytes 2018-10-25 12:40:39,676 INFO     org.apache.flink.client.cli.CliFrontend-     JAVA_HOME:/usr/java/jdk1.8.0_172 2018-10-25 12:40:39,678信息     org.apache.flink.client.cli.CliFrontend-     Hadoop版本:2.6.5 2018-10-25 12:40:39,678信息     org.apache.flink.client.cli.CliFrontend-JVM     选项:2018-10-25 12:40:39,678信息     org.apache.flink.client.cli.CliFrontend-
    -Dlog.file = / root / flink-1.6.1 / log / flink-root-client-cuiyk-cdn-test-10.log     2018-10-25 12:40:39,678信息org.apache.flink.client.cli.CliFrontend     --Dlog4j.configuration =文件:/root/flink-1.6.1/conf/log4j-cli.properties 2018-10-25 12:40:39,678 INFO org.apache.flink.client.cli.CliFrontend     --Dlogback.configurationFile = file:/root/flink-1.6.1/conf/logback.xml 2018-10-25 12:40:39,678 INFO org.apache.flink.client.cli.CliFrontend     -程序参数:2018-10-25 12:40:39,678信息org.apache.flink.client.cli.CliFrontend-
    运行2018-10-25 12:40:39,678信息     org.apache.flink.client.cli.CliFrontend--c     2018-10-25 12:40:39,678信息org.apache.flink.client.cli.CliFrontend     -dataclean.FlinkDataCleanDemo 2018-10-25 12:40:39,678信息org.apache.flink.client.cli.CliFrontend-
    --parallelism 2018-10-25 12:40:39,678信息org.apache.flink.client.cli.CliFrontend-4     2018-10-25 12:40:39,678信息org.apache.flink.client.cli.CliFrontend     ---jobmanager 2018-10-25 12:40:39,679信息org.apache.flink.client.cli.CliFrontend-
    cuiyk-cdn-test-4:42115 2018-10-25 12:40:39,679信息     org.apache.flink.client.cli.CliFrontend-
    ./flinkkafka2tsdb.jar 2018-10-25 12:40:39,679信息     org.apache.flink.client.cli.CliFrontend-     类路径:     /root/flink-1.6.1/lib/flink-python_2.11-1.6.1.jar:/root/flink-1.6.1/lib/flink-shaded-hadoop2-uber-1.6.1.jar:/root /flink-1.6.1/lib/log4j-1.2.17.jar:/root/flink-1.6.1/lib/slf4j-log4j12-1.7.7.jar:/root/flink-1.6.1/lib/flink -dist_2.11-1.6.1.jar :: / opt / cloudera / parcels / CDH-5.13.3-1.cdh5.13.3.p0.2 / lib / hadoop / etc / hadoop:     2018-10-25 12:40:39,679信息org.apache.flink.client.cli.CliFrontend     -------------------------------------------------- ------------------------------- 2018-10-25 12:40:39,682信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:classloader.resolve-order,     parent-first 2018-10-25 12:40:39,682信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:jobmanager.rpc.address,本地主机     2018-10-25 12:40:39,682信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:jobmanager.rpc.port,6123 2018-10-25     12:40:39,682信息org.apache.flink.configuration.GlobalConfiguration     -加载配置属性:jobmanager.heap.size,1024m 2018-10-25 12:40:39,682信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:taskmanager.heap.size,1024m     2018-10-25 12:40:39,683信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:taskmanager.numberOfTaskSlots,1     2018-10-25 12:40:39,683信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:parallelism.default,1 2018-10-25     12:40:39,683信息org.apache.flink.configuration.GlobalConfiguration     -加载配置属性:rest.port,8081 2018-10-25 12:40:39,696信息org.apache.flink.yarn.cli.FlinkYarnSessionCli
    -在/tmp/.yarn-properties-root下找到了Yarn属性文件。 2018-10-25 12:40:39,914信息     org.apache.flink.runtime.security.modules.HadoopModule-Hadoop     用户设置为root(auth:SIMPLE)2018-10-25 12:40:39,936 INFO     org.apache.flink.client.cli.CliFrontend-     运行“运行”命令。 2018-10-25 12:40:39,940信息     org.apache.flink.client.cli.CliFrontend-     JAR文件中的构建程序2018-10-25 12:40:40,314 INFO     org.apache.flink.runtime.rest.RestClient-休息     客户端端点已启动。 2018-10-25 12:40:40,316信息     org.apache.flink.client.cli.CliFrontend-     开始执行程序2018-10-25 12:40:40,316 INFO     org.apache.flink.client.program.rest.RestClusterClient-     以交互模式启动程序(超脱:假)2018-10-25     12:40:40,346警告     org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer09-     忽略已配置的密钥反序列化器(key.deserializer)2018-10-25     12:40:40,346警告     org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer09-     忽略配置的值DeSerializer(value.deserializer)2018-10-25     12:40:40,532信息org.apache.flink.configuration.GlobalConfiguration     -加载配置属性:classloader.resolve-order,parent-first 2018-10-25 12:40:40,532信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:jobmanager.rpc.address,本地主机     2018-10-25 12:40:40,532信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:jobmanager.rpc.port,6123 2018-10-25     12:40:40,532信息org.apache.flink.configuration.GlobalConfiguration     -加载配置属性:jobmanager.heap.size,1024m 2018-10-25 12:40:40,532信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:taskmanager.heap.size,1024m     2018-10-25 12:40:40,532信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:taskmanager.numberOfTaskSlots,1     2018-10-25 12:40:40,532信息     org.apache.flink.configuration.GlobalConfiguration-     加载配置属性:parallelism.default,1 2018-10-25     12:40:40,533信息org.apache.flink.configuration.GlobalConfiguration     -加载配置属性:rest.port,8081 2018-10-25 12:40:40,540信息     org.apache.flink.client.program.rest.RestClusterClient-     提交作业1b45b5780e0e7067fae20be1db8e7c2f(分离:false)。     2018-10-25 12:41:38,177信息org.apache.flink.runtime.rest.RestClient     -关闭休息端点。 2018-10-25 12:41:38,179 INFO org.apache.flink.runtime.rest.RestClient-休息     端点关闭完成。 2018-10-25 12:41:38,180错误     org.apache.flink.client.cli.CliFrontend-错误     在运行命令时。     org.apache.flink.client.program.ProgramInvocationException:作业     失败了(工作ID:1b45b5780e0e7067fae20be1db8e7c2f)             在org.apache.flink.client.program.rest.RestClusterClient.submitJob(RestClusterClient.java:267)             在org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:486)             在org.apache.flink.streaming.api.environment.StreamContextEnvironment.execute(StreamContextEnvironment.java:66)             在org.apache.flink.streaming.api.scala.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.scala:654)处             在dataclean.FlinkDataCleanDemo $ .main(FlinkDataCleanDemo.scala:162)             在dataclean.FlinkDataCleanDemo.main(FlinkDataCleanDemo.scala)             在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处             在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)             在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)             在java.lang.reflect.Method.invoke(Method.java:498)             在org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:529)             在org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:421)             在org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:426)             在org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:804)             在org.apache.flink.client.cli.CliFrontend.runProgram(CliFrontend.java:280)             在org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:215)             在org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1044)             在org.apache.flink.client.cli.CliFrontend.lambda $ main $ 11(CliFrontend.java:1120)             在java.security.AccessController.doPrivileged(本机方法)             在javax.security.auth.Subject.doAs(Subject.java:422)             在org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1692)             在org.apache.flink.runtime.security.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41)             在org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1120)     原因:java.lang.NoClassDefFoundError:无法初始化类     org.apache.http.conn.ssl.SSLConnectionSocketFactory             在org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:912)             在org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)             在dataclean.CommonDeploy $ .saveToOpenTSDB(CommonDeploy.scala:21)             在dataclean.FlinkDataCleanDemo $$ anonfun $ main $ 1.apply(FlinkDataCleanDemo.scala:152)             在dataclean.FlinkDataCleanDemo $$ anonfun $ main $ 1.apply(FlinkDataCleanDemo.scala:150)             在org.apache.flink.streaming.api.scala.DataStream $$ anon $ 4.map(DataStream.scala:607)             在org.apache.flink.streaming.api.operators.StreamMap.processElement(StreamMap.java:41)             在org.apache.flink.streaming.runtime.tasks.OperatorChain $ CopyingChainingOutput.pushToOperator(OperatorChain.java:579)处             在org.apache.flink.streaming.runtime.tasks.OperatorChain $ CopyingChainingOutput.collect(OperatorChain.java:554)             在org.apache.flink.streaming.runtime.tasks.OperatorChain $ CopyingChainingOutput.collect(OperatorChain.java:534)             在org.apache.flink.streaming.api.operators.AbstractStreamOperator $ CountingOutput.collect(AbstractStreamOperator.java:689)             在org.apache.flink.streaming.api.operators.AbstractStreamOperator $ CountingOutput.collect(AbstractStreamOperator.java:667)             在org.apache.flink.streaming.api.operators.TimestampedCollector.collect(TimestampedCollector.java:51)             位于org.apache.flink.streaming.api.scala.DataStream $$ anon $ 6 $$ anonfun $ flatMap $ 1.apply(DataStream.scala:663)             位于org.apache.flink.streaming.api.scala.DataStream $$ anon $ 6 $$ anonfun $ flatMap $ 1.apply(DataStream.scala:663)             在scala.collection.LinearSeqOptimized $ class.foreach(LinearSeqOptimized.scala:73)             在scala.collection.mutable.MutableList.foreach(MutableList.scala:30)             在org.apache.flink.streaming.api.scala.DataStream $$ anon $ 6.flatMap(DataStream.scala:663)             在org.apache.flink.streaming.api.operators.StreamFlatMap.processElement(StreamFlatMap.java:50)             在org.apache.flink.streaming.runtime.tasks.OperatorChain $ CopyingChainingOutput.pushToOperator(OperatorChain.java:579)处             在org.apache.flink.streaming.runtime.tasks.OperatorChain $ CopyingChainingOutput.collect(OperatorChain.java:554)             在org.apache.flink.streaming.runtime.tasks.OperatorChain $ CopyingChainingOutput.collect(OperatorChain.java:534)             在org.apache.flink.streaming.api.operators.AbstractStreamOperator $ CountingOutput.collect(AbstractStreamOperator.java:689)             在org.apache.flink.streaming.api.operators.AbstractStreamOperator $ CountingOutput.collect(AbstractStreamOperator.java:667)             在org.apache.flink.streaming.api.operators.StreamMap.processElement(StreamMap.java:41)             在org.apache.flink.streaming.runtime.io.StreamInputProcessor.processInput(StreamInputProcessor.java:202)             在org.apache.flink.streaming.runtime.tasks.OneInputStreamTask.run(OneInputStreamTask.java:105)             在org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:300)             在org.apache.flink.runtime.taskmanager.Task.run(Task.java:711)             在java.lang.Thread.run(Thread.java:748)

  
//related dependecies:
    <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.4</version>
        </dependency>

1 个答案:

答案 0 :(得分:1)

我刚刚通过在“配置”标签的maven shade插件中添加此问题来解决了这个问题,如下所示:

                    <relocations>
                        <relocation>
                            <pattern>org.apache.http</pattern>
                            <shadedPattern>shade.org.apache.http</shadedPattern>
                        </relocation>
                    </relocations>