Cannot run unit test from IDE, but command line run succeeds

Answered

I have a gradle project that am able to successfully run test from the command line.

However the same fails when I run it from IDE. What are the possibilities of this happening ? I have also edited the Run configurations and addded my "compileTestJava" task also in addition to "make". 

 

The error I get from IDE is below. Again I repeat I am able to run the test just fine from command line (gradle test) 

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/sseshac/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.6.6/5cd9b4fbc3ff6a97beaade3206137d76f65df805/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/sseshac/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.1.3/d90276fff414f06cb375f2057f6778cd63c6082f/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
....
....
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
at org.apache.log4j.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:50)
... 37 more

java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.Log4jLoggerFactory
at org.apache.log4j.LogManager.getLogger(LogManager.java:45)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:284)

 

4 comments
Comment actions Permalink

Please share a sample project to reproduce.

0
Comment actions Permalink

I am unable to share a sample project as this is something I am seeing this only in a particular  project the source code of which I obviously cannot share. 

But my question now is this  - "gradle dependencies" is going to give me entire dependency tree that will help me debug and fix any jar hell problems. Is it possible to do something similar in IntelliJ (like tryinng to figure the classpath that will be used).

0
Comment actions Permalink

You can see the classpath in the Run console when you start the app. If it's too long for your OS to handle, IDEA will create a dummy jar file with the manifest containing the classpath, you'll see it in the command line.

0
Comment actions Permalink

I got the classpath and excluded it from my gradle. (But I still find it confusing that when run through gradle, it didnt complain).

Anyway thanks for the help 

0

Please sign in to leave a comment.