java.lang.ExceptionInInitializerError

GitHub | spencergibb | 3 months ago
  1. 0

    h4. Status Quo The {{spring-test-mvc}} builds fine from the command line with Gradle; however, when Eclipse projects are created with the {{import-into-eclipse.sh}} script and the tests in {{spring-test-mvc}} are then executed within Eclipse, we run into classpath issues. For example, if you execute {{MockMvcClientHttpRequestFactoryTests}} within Eclipse, you will see the following messages in the console: {noformat} SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Users/sbrannen/.gradle/caches/artifacts-15/filestore/org.slf4j/slf4j-jcl/1.6.1/jar/b5902b1ba8ec58a96140bb7445037b3512cc99bb/slf4j-jcl-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/Users/sbrannen/.gradle/caches/artifacts-15/filestore/org.slf4j/slf4j-log4j12/1.6.1/jar/bd245d6746cdd4e6203e976e21d597a46f115802/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. SLF4J: See also http://www.slf4j.org/codes.html#jclDelegationLoop for more details. {noformat} And the test fails with the following stacktrace: {noformat} java.lang.ExceptionInInitializerError at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:82) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:51) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<clinit>(SpringJUnit4ClassRunner.java:91) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:58) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:58) at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:27) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.IllegalStateException: Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#jclDelegationLoop for more details. at org.slf4j.impl.JCLLoggerFactory.<clinit>(JCLLoggerFactory.java:64) ... 28 more {noformat} h4. Analysis As a result of work performed in conjunction with SPR-9421, all other modules that require SLF4J for tests now declare a dependency on {{slf4j-jcl}}; however, {{spring-test-mvc}} still declares test dependencies on {{jcl-over-slf4j}} and {{slf4j-log4j12}}. Furthermore, it appears that some dependency of {{spring-test-mvc}} pulls in a transitive dependency on {{jcl-over-slf4j:1.5.8}} which may be the underlying source of the problem. h4. Deliverables # (/) Modify the Gradle build (i.e., the dependency management) so that the generated Eclipse {{.classpath}} for {{spring-test-mvc}} allows tests to run within Eclipse as well as from the command line with Gradle.

    Spring JIRA | 4 years ago | Sam Brannen
    java.lang.ExceptionInInitializerError
  2. 0

    h4. Status Quo The {{spring-test-mvc}} builds fine from the command line with Gradle; however, when Eclipse projects are created with the {{import-into-eclipse.sh}} script and the tests in {{spring-test-mvc}} are then executed within Eclipse, we run into classpath issues. For example, if you execute {{MockMvcClientHttpRequestFactoryTests}} within Eclipse, you will see the following messages in the console: {noformat} SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Users/sbrannen/.gradle/caches/artifacts-15/filestore/org.slf4j/slf4j-jcl/1.6.1/jar/b5902b1ba8ec58a96140bb7445037b3512cc99bb/slf4j-jcl-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/Users/sbrannen/.gradle/caches/artifacts-15/filestore/org.slf4j/slf4j-log4j12/1.6.1/jar/bd245d6746cdd4e6203e976e21d597a46f115802/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. SLF4J: See also http://www.slf4j.org/codes.html#jclDelegationLoop for more details. {noformat} And the test fails with the following stacktrace: {noformat} java.lang.ExceptionInInitializerError at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:82) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:51) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<clinit>(SpringJUnit4ClassRunner.java:91) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:58) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:58) at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:27) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.IllegalStateException: Detected both jcl-over-slf4j.jar AND slf4j-jcl.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#jclDelegationLoop for more details. at org.slf4j.impl.JCLLoggerFactory.<clinit>(JCLLoggerFactory.java:64) ... 28 more {noformat} h4. Analysis As a result of work performed in conjunction with SPR-9421, all other modules that require SLF4J for tests now declare a dependency on {{slf4j-jcl}}; however, {{spring-test-mvc}} still declares test dependencies on {{jcl-over-slf4j}} and {{slf4j-log4j12}}. Furthermore, it appears that some dependency of {{spring-test-mvc}} pulls in a transitive dependency on {{jcl-over-slf4j:1.5.8}} which may be the underlying source of the problem. h4. Deliverables # (/) Modify the Gradle build (i.e., the dependency management) so that the generated Eclipse {{.classpath}} for {{spring-test-mvc}} allows tests to run within Eclipse as well as from the command line with Gradle.

    Spring JIRA | 4 years ago | Sam Brannen
    java.lang.ExceptionInInitializerError
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    GitHub comment 3#6696038

    GitHub | 4 years ago | dblock
    java.lang.ExceptionInInitializerError

    5 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. 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.<clinit>()
    2. SLF4J LOG4J-12 Binding
      StaticLoggerBinder.<clinit>
      1. org.slf4j.impl.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:54)
      2. org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:72)
      3. org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45)
      3 frames
    3. SLF4J API Module
      LoggerFactory.getLogger
      1. org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
      2. org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
      3. org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
      4. org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
      4 frames
    4. Apache Commons Logging
      LogFactory.getLog
      1. org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
      2. org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
      3. org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
      3 frames
    5. Spring Boot
      SpringApplication.<clinit>
      1. org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:189)
      1 frame
    6. Java RT
      Constructor.newInstance
      1. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      2. sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      3. sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      4. java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      4 frames
    7. Spring Boot CLI
      SpringApplicationRunner$RunThread.run
      1. org.springframework.boot.cli.app.SpringApplicationLauncher.launch(SpringApplicationLauncher.java:65)
      2. org.springframework.boot.cli.command.run.SpringApplicationRunner$RunThread.run(SpringApplicationRunner.java:169)
      2 frames