Using CallbackParams in conjunction with spring test runner results in classloading clashes.
Use Callback Params with conjunction with spring runner:
@RunWith(CallbackParamsRunner.class)
@WrappedRunner(SpringJUnit4ClassRunner.class)
-
Use a logger in your test class
private static Log logger;
-
Running the test will result in the following error
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [org.callbackparams.internal.CallbackTestClassReloader@3e401b01] whereas object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [sun.misc.Launcher$AppClassLoader@17072b90].
log4j:ERROR Could not instantiate appender named "rfile".
log4j:WARN No appenders could be found for logger (org.springframework.test.context.TestContextManager).
log4j:WARN Please initialize the log4j system properly.
Is this a known issue?
cheers
Artur
It seems that step 2 is not even required.
It's enough to use step 1 and the error is thrown when spring tries to configure log4j
Ok, I am not sure if this is a valid bug for the project
passing
-Dlog4j.ignoreTCL=true
solved the problem. The logger is working now correctly.
This is a valid bug.
The root problem seems to be that the thread-context classloader is not properly set when the wrapped runner is initialized.
A fix will come in the next release (1.0-beta-7), which will be available some time during Q1 2015.