Menu

#4 class loading conflicts with springjunit4classrunner

v1.0_(example)
accepted
None
8
2014-12-27
2014-11-17
Artur
No

Using CallbackParams in conjunction with spring test runner results in classloading clashes.

  1. Use Callback Params with conjunction with spring runner:

    @RunWith(CallbackParamsRunner.class)
    @WrappedRunner(SpringJUnit4ClassRunner.class)

  2. Use a logger in your test class

    private static Log logger;

  3. 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

Discussion

  • Artur

    Artur - 2014-11-17

    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

     
  • Artur

    Artur - 2014-11-17

    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.

     
  • Henrik Kaipe

    Henrik Kaipe - 2014-12-27
    • status: open --> accepted
    • Priority: 5 --> 8
     
  • Henrik Kaipe

    Henrik Kaipe - 2014-12-27

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.