Menu

#134 Log4j classes reloaded by IsolatingClassLoader

closed
5
2014-05-02
2008-11-19
Fei Fan
No

I use Grinder 3.1, GrinderStone 2.0 and PyDev 1.3.22 in Eclipse 3.4.1. I've used log4j in my test project to output running logs. Things go well with normal running. But when I started the test run in debug mode, which will casue the Grinder to run in single process mode. log4j classes seems to be reloaded by net.grinder.util.IsolatingClassLoader. It will cause log4j to fail initializing:
08-11-19 14:27:28 (agent): The Grinder 3.1
08-11-19 14:27:28 (agent): DEBUG MODE: Spawning threads rather than processes
08-11-19 14:27:28 (agent): WARNING grinder.jvm.arguments (-Xmx256m) ignored in single process mode
08-11-19 14:27:28 (agent): worker CN-PC-HZ2110-0 started
08-11-19 14:27:28 (process CN-PC-HZ2110-0): INFO: Starting new GrinderStone Debug process...
08-11-19 14:27:29 (process CN-PC-HZ2110-0): starting threads
08-11-19 14:27:29 (thread 0 run 0): INFO: Start debugging main script...
08-11-19 14:27:29 (thread 0 run 0): INFO: Grinder debugger is started.
log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [net.grinder.util.IsolatingClassLoader@bf32c] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [sun.misc.Launcher$AppClassLoader@19821f].
log4j:ERROR Could not instantiate appender named "stdout".
log4j:ERROR A "org.apache.log4j.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [net.grinder.util.IsolatingClassLoader@bf32c] whereas object of type
log4j:ERROR "org.apache.log4j.FileAppender" was loaded by [sun.misc.Launcher$AppClassLoader@19821f].

After examing the code of IsolatingClassLoader, it seems the classes other than the shared ones will be reloaded. A walk around is to modify the caller net.grinder.engine.agent.DebugThreadWorker to include "org.apache.log4j.*" in its SHARED_CLASSES set:

private static final String[] SHARED_CLASSES = {
IsolateGrinderProcessRunner.class.getName(),
"org.apache.log4j.*",
};

Discussion

<< < 1 .. 7 8 9 10 11 .. 34 > >> (Page 9 of 34)
<< < 1 .. 7 8 9 10 11 .. 34 > >> (Page 9 of 34)

Log in to post a comment.