Scala 火花动作投掷';类路径包含多个SLF4J绑定';来自oozie的错误

Scala 火花动作投掷';类路径包含多个SLF4J绑定';来自oozie的错误,scala,maven,Scala,Maven,我有一个scala jar文件,它从配置单元视图读取数据,并在hdfs中创建一个csv文件。当从CLI调用时,这个jar在spark cluster模式下运行良好,但当从Oozie工作流触发时,它抛出以下错误 SLF4J : Classpath contains multiple SLF4J bindings. SLF4J : Found binding in [jar:file:/data/hadoop-data/9/yarn/nm/filecache/7505/slf4j-log4j12

我有一个scala jar文件,它从配置单元视图读取数据,并在hdfs中创建一个csv文件。当从CLI调用时,这个jar在spark cluster模式下运行良好,但当从Oozie工作流触发时,它抛出以下错误

 SLF4J : Classpath contains multiple SLF4J bindings.
 SLF4J : Found binding in [jar:file:/data/hadoop-data/9/yarn/nm/filecache/7505/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
 SLF4J : Found binding in [jar:file:/data/hadoop-data/1/yarn/nm/usercache/cntr/filecache/216569/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
 SLF4J : Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.8.3-1.cdh5.8.3.p2256.2455/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]

 SLF4J : Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
我做了一些搜索,发现在pom.xml的依赖项中添加排除项可以达到目的,所以我在pom.xml的排除项中添加了以下内容

 <exclusions>
    <exclusion>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
    </exclusion>
    <exclusion>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
    </exclusion>
    <exclusion>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
    </exclusion>
 </exclusions>

org.slf4j
slf4j-log4j12
log4j
log4j
org.slf4j
slf4j api
但当我从oozie工作流触发spark jar时,仍然会遇到同样的错误


欢迎任何建议

这里有另一种检查绑定的方法。我假设您正在使用eclipse进行开发,这是一个maven项目

  • 转到pom.xml
  • 在dependencies选项卡中,搜索绑定(以slf4j为例)
  • 右键单击所有并排除它们
它的基本功能是向pom.xml添加排除块,就像前面提到的那样,其优点是您可以查看该依赖关系是否来自任何其他库

让我知道这是否有帮助。
干杯。

这是由于不同的
jar使用了
slf4j
的多个
jar
。更简单的解决方案是在依赖项中添加最新或更高版本的
slf4j
,强制只使用最新的
jar
,这将是向后兼容的

您还可以运行
mvn dependency:tree
,搜索slf4j的实现,并将其排除在外

    <exclusions>
      <exclusion> 
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
      </exclusion>
      <exclusion> 
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
      </exclusion>
    </exclusions> 

org.slf4j
slf4j-log4j12
log4j
log4j

希望这有帮助

在进一步研究日志文件后,我发现问题是由于没有正确地将hive-site.xml传递给spark action,spark action希望从oozie工作流获得hive-site.xml,因为我的spark作业包含对hive表的引用。通过hive-site.xml后,问题得到了解决


谢谢大家的时间和建议。

这是因为您的类路径中有多个
slf4j-log4j12-1.7.5.jar
,您可以从错误中看到这一点。我猜这不是一个错误,这只是信息,不是吗?嗨@RameshMaharjan,这是来自oozie的stderr,正因为如此,spark动作失败了,当从命令行界面hi@chitral verma运行jar时,jar在集群中成功运行,因此我尝试在pom.xml的dependencies选项卡中查找slf4j,但没有找到任何要排除的对象,而不是dependencies选项卡。您可以使用相同的dependency hierarchy选项卡吗?