java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError

刘超 18天前 ⋅ 116 阅读   编辑

一、描述

  idea执行spark程序,报如下错误

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/Resource/LocalRepository/org/slf4j/slf4j-log4j12/1.7.16/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/Resource/LocalRepository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. 
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
Exception in thread "main" java.lang.ExceptionInInitializerError
	at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
	at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:143)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:122)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:378)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:328)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:349)
	at org.apache.spark.network.util.JavaUtils.(JavaUtils.java:41)
	at org.apache.spark.internal.config.ConfigHelpers$.byteFromString(ConfigBuilder.scala:67)
	at org.apache.spark.internal.config.ConfigBuilder$$anonfun$bytesConf$1.apply(ConfigBuilder.scala:235)
	at org.apache.spark.internal.config.ConfigBuilder$$anonfun$bytesConf$1.apply(ConfigBuilder.scala:235)
	at org.apache.spark.internal.config.TypedConfigBuilder$$anonfun$transform$1.apply(ConfigBuilder.scala:101)
	at org.apache.spark.internal.config.TypedConfigBuilder$$anonfun$transform$1.apply(ConfigBuilder.scala:101)
	at org.apache.spark.internal.config.TypedConfigBuilder.createWithDefault(ConfigBuilder.scala:143)
	at org.apache.spark.internal.config.package$.(package.scala:121)
	at org.apache.spark.internal.config.package$.(package.scala)
	at org.apache.spark.SparkConf$.(SparkConf.scala:716)
	at org.apache.spark.SparkConf$.(SparkConf.scala)
	at org.apache.spark.SparkConf.set(SparkConf.scala:95)
	at org.apache.spark.SparkConf.set(SparkConf.scala:84)
	at org.apache.spark.sql.SparkSession$Builder$$anonfun$7$$anonfun$apply$6.apply(SparkSession.scala:928)
	at org.apache.spark.sql.SparkSession$Builder$$anonfun$7$$anonfun$apply$6.apply(SparkSession.scala:928)
	at scala.collection.mutable.HashMap.$anonfun$foreach$1(HashMap.scala:138)
	at scala.collection.mutable.HashTable.foreachEntry(HashTable.scala:236)
	at scala.collection.mutable.HashTable.foreachEntry$(HashTable.scala:229)
	at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
	at scala.collection.mutable.HashMap.foreach(HashMap.scala:138)
	at org.apache.spark.sql.SparkSession$Builder$$anonfun$7.apply(SparkSession.scala:928)
	at org.apache.spark.sql.SparkSession$Builder$$anonfun$7.apply(SparkSession.scala:926)
	at scala.Option.getOrElse(Option.scala:121)
	at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:926)
	at net.itdiandi.batch.spark.checkout.CheckPointDemo$.main(CheckPointDemo.scala:7)
	at net.itdiandi.batch.spark.checkout.CheckPointDemo.main(CheckPointDemo.scala)
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
	at org.slf4j.impl.Log4jLoggerFactory.(Log4jLoggerFactory.java:54)
	... 33 more

二、解决方法

  log4j-over-slf4j.jar与slf4j-log4j12.jar不能同时使用,删掉,如下依赖

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>log4j-over-slf4j</artifactId>
    <version>1.7.24</version>
</dependency>

  


注意:本文归作者所有,未经作者允许,不得转载

全部评论: 0

    我有话说: