66

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.

How can this problem be solved?

starball
  • 20,030
  • 7
  • 43
  • 238
Yuvraj Kakkar
  • 1,123
  • 1
  • 11
  • 24
  • 4
    If you are using log4j, you could simply exclude the `log4j-over-slf4j.jar`. In theory using log4j and hacking other code to route the log4j calls to slf4j can lead to recursion and hence the strict check. – M. Deinum Nov 21 '13 at 12:11

7 Answers7

83

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.

Tomas Hanus
  • 1,056
  • 1
  • 8
  • 10
  • 4
    That is because some dependencies that you add will have the logs libraries of their choice and so cause conflicts. – Karthik Jan 20 '15 at 09:51
  • 1
    You should also remove the log4j jar that has been added to your classpath. Check your lib folder of storm. Atleast it was the case with me. – Amit Kumar Oct 05 '15 at 11:10
  • I could only get a SpringBoot application after I added that. – Marcello DeSales Aug 09 '16 at 15:23
  • 3
    In which tag do we add this exclusion? I've tried in the 'spring-boot-starter-web' exclusions but did not work. Which dependency? – Jeach Feb 21 '17 at 22:02
  • 1
    This is the exclusion that worked for me: org.slf4j * – Erica Jul 24 '19 at 09:38
  • In which tag do we add this exclusion? – arj Sep 04 '19 at 08:34
  • To figure out which dependency to put the exclusion in, run `mvn dependency:tree`. Search the results for `slf4j-log4j12`. Whichever artifact within the module's pom that's bringing in the log4j12 dependency is the artifact you want to put the exclusion in. – takanuva15 May 18 '20 at 21:28
4

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!

Duncan O. N.
  • 778
  • 12
  • 24
3

And for SBT : excludeDependencies += "log4j" % "log4j"

Ismail H
  • 4,226
  • 2
  • 38
  • 61
2

I got the solution

download Xuggler 5.4 here

and some more jar to make it work...

commons-cli-1.1.jar

commons-lang-2.1.jar

logback-classic-1.0.0.jar

logback-core-1.0.0.jar

slf4j-api-1.6.4.jar

Reference Libraries

You can check which dependencies xuggler needs from here:

Add this jars and xuggle-xuggler-5.4.jar to your project's build path and it s ready.

**version numbers may change

Yuvraj Kakkar
  • 1,123
  • 1
  • 11
  • 24
2

For gradle

compile('org.xxx:xxx:1.0-SNAPSHOT'){
    exclude module: 'log4j'
    exclude module: 'slf4j-log4j12'
}
petertc
  • 3,607
  • 1
  • 31
  • 36
0

SBT solution stated above did not work for me. What worked for me is excluding slf4j-log4j12

//dependencies with exclusions
libraryDependencies ++= Seq(
    //depencies
).map(_.exclude("org.slf4j","slf4j-log4j12"))
Arosha
  • 1,311
  • 2
  • 16
  • 22
0

You need to exclude log4j-over-slf4j

<dependency>
    ....
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>
isopropylcyanide
  • 423
  • 4
  • 16