Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.

Tags:

java

jar

I have used xuggle library in my project to trans code the video from mp4 to flv. I have used slf4j libraries also to support logging end.

import com.xuggle.mediatool.IMediaReader; import com.xuggle.mediatool.IMediaViewer; import com.xuggle.mediatool.IMediaWriter; import com.xuggle.mediatool.ToolFactory;  public class TranscodingExample {      private static final String inputFilename = "E:\\VIDEO\\Facebook.mp4";     private static final String outputFilename = "E:\\VIDEO\\Facebook.flv";      public static void main(String[] args) {          // create a media reader         IMediaReader mediaReader =                 ToolFactory.makeReader(inputFilename);          // create a media writer         IMediaWriter mediaWriter =                 ToolFactory.makeWriter(outputFilename, mediaReader);          // add a writer to the reader, to create the output file         mediaReader.addListener(mediaWriter);          // create a media viewer with stats enabled         IMediaViewer mediaViewer = ToolFactory.makeViewer(true);          // add a viewer to the reader, to see the decoded media         mediaReader.addListener(mediaViewer);          // read and decode packets from the source file and         // and dispatch decoded audio and video to the writer         while (mediaReader.readPacket() == null) ;      }  } 

Here I am getting an error

"Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.".  

I have used both jar files as libraries in order to solve logging problems. Does any one faced the same problem.If so kindly write suggestion or solution to come out of this mess. Thanks in advance.

like image 437
Yuvraj Kakkar Avatar asked Nov 21 '13 10:11

Yuvraj Kakkar


People also ask

Is log4j over SLF4J jar vulnerable?

As such, using log4j 2. x, even via SLF4J does not mitigate the vulnerability. However, as mentioned already, log4j 1. x is safe with respect to CVE-2021-44228.

What is log4j over SLF4J?

log4j-over-slf4j. SLF4J ship with a module called log4j-over-slf4j. It allows log4j users to migrate existing applications to SLF4J without changing a single line of code but simply by replacing the log4j. jar file with log4j-over-slf4j.

What is SLF4J error?

impl. StaticLoggerBinder". This is a warning which is caused when there are no SLF4J bindings provided in the classpath.

What is SLF4J jdk14?

slf4j is Simple Logging Facade for Java .


2 Answers

So you have to exclude conflict dependencies. Try this:

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

This solved same problem with slf4j and Dozer.

like image 139
Tomas Hanus Avatar answered Sep 28 '22 10:09

Tomas Hanus


Encountered a similar error, this how I resolved it:

  1. Access Project explorer view on Netbeans IDE 8.2. Proceed to your project under Dependencies hover the cursor over the log4j-over-slf4j.jar to view the which which dependencies have indirectly imported as shown below. enter image description here

  2. Right click an import jar file and select Exclude Dependency enter image description here

  3. To confirm, open your pom.xml file you will notice the exclusion element as below.

enter image description here 4. Initiate maven clean install and run your project. Good luck!

like image 40
Dun0523 Avatar answered Sep 28 '22 11:09

Dun0523