getting initializationError0 while using @RunWith(SpringJUnit4ClassRunner.class) - Spring Forum
Ok, Fixed the issue. Via transitive dependency, I was using the log4j-over-slf4j jar, we was using the 1.5.6 version, because slf4j's implementation does not contain all the log4j source code, there will always be NoClassDefFoundError when trying to invoke a log4J class that does not exist, and in my case, the source of the log4j-over-slf4j.jar we are using does not have the LogManager class in it.I went down the route of getting the latest implementation (log4j-over-slf4j-1.6.1.jar) which although it has the LogManager class in it, you still run into further errors because supporting jars e.g. slf4j-api, slf4j-log4j12 are either not compatible or they do not have the required class.
Because log4j is already available, we did not really need the slf4j implementations in the current project, hence excluding log4j-over-slf4j in my immediate pom meant that this jar was not added to my classpath, and my test code just used the log4j implementation and it worked.
Sample exclusion code:
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
If using eclipse and you have the m2eclipse plugin installed, using the dependency hierarchy tab, you can see the dependency using this artifact, just add the exclusion code to this dependency.
Read full article from getting initializationError0 while using @RunWith(SpringJUnit4ClassRunner.class) - Spring Forum
No comments:
Post a Comment