I'm trying to run my junit classes using emma (great tool by the way).
When I put the non-instrumented classes in front of the classpath, all is fine and the unit tests run. When putting the instrumented ones in front, junit gives this:
[junit] Caused an ERROR
[junit] null
[junit] java.lang.reflect.InvocationTargetException
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[junit] Caused by: java.lang.ExceptionInInitializerError
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:141)
[junit] at org.apache.log4j.Logger.class$(Logger.java:25)
[junit] at org.apache.log4j.Logger.<clinit>(Logger.java:25)
[junit] at be.realsoftware.ivs.algo.ols.OrdinaryLeastSquaresTest.<clinit
>(OrdinaryLeastSquaresTest.java:26)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:141)
[junit] at be.realsoftware.ivs.algo.ols.OlsSuite.suite(OlsSuite.java:29)
[junit] at be.realsoftware.ivs.algo.AlgoSuite.suite(AlgoSuite.java:33)
[junit] at be.realsoftware.ivs.IVSSuite.suite(Unknown Source)
[junit] ... 7 more
[junit] Caused by: java.lang.NullPointerException
[junit] at org.apache.log4j.Level.<init>(Level.java)
[junit] at org.apache.log4j.Priority.<clinit>(Priority.java:37)
[junit] ... 17 more
The offending line is the following (Logger is a standard log4j 1.2.8 class) :
/** logger */
private static final Logger logger = Logger.getLogger(OrdinaryLeastSquaresTest.class);
I guess it's some kind of reflection thing. Has anyone experienced this before, is it a bug, ...
greetings,
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This seems to be an issue similar to the one already reported to me by a Trilogy user. I am certain it is related to classloading when you use emmarun or when you let junit (and ANT) do their (very incorrectly coded, I am afraid http://discuss.develop.com/archives/wa.exe?A2=ind0302&L=ADVANCED-JAVA&P=R16312&I=-3\) testcase classloading. It will be a high priority issue to address once I am done with the house move mentioned earlier in this forum.
If you are using the offline instrumentation mode (seems like you are according to your post), try the following:
- try forking <junit> (fork="true")
If this does not help, submit a bug report to the tracker that contains your exact <junit> invocation and attach the result of running "ant -debug ...".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm trying to run my junit classes using emma (great tool by the way).
When I put the non-instrumented classes in front of the classpath, all is fine and the unit tests run. When putting the instrumented ones in front, junit gives this:
[junit] Caused an ERROR
[junit] null
[junit] java.lang.reflect.InvocationTargetException
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[junit] Caused by: java.lang.ExceptionInInitializerError
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:141)
[junit] at org.apache.log4j.Logger.class$(Logger.java:25)
[junit] at org.apache.log4j.Logger.<clinit>(Logger.java:25)
[junit] at be.realsoftware.ivs.algo.ols.OrdinaryLeastSquaresTest.<clinit
>(OrdinaryLeastSquaresTest.java:26)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:141)
[junit] at be.realsoftware.ivs.algo.ols.OlsSuite.suite(OlsSuite.java:29)
[junit] at be.realsoftware.ivs.algo.AlgoSuite.suite(AlgoSuite.java:33)
[junit] at be.realsoftware.ivs.IVSSuite.suite(Unknown Source)
[junit] ... 7 more
[junit] Caused by: java.lang.NullPointerException
[junit] at org.apache.log4j.Level.<init>(Level.java)
[junit] at org.apache.log4j.Priority.<clinit>(Priority.java:37)
[junit] ... 17 more
The offending line is the following (Logger is a standard log4j 1.2.8 class) :
/** logger */
private static final Logger logger = Logger.getLogger(OrdinaryLeastSquaresTest.class);
I guess it's some kind of reflection thing. Has anyone experienced this before, is it a bug, ...
greetings,
Mike
Mike,
This seems to be an issue similar to the one already reported to me by a Trilogy user. I am certain it is related to classloading when you use emmarun or when you let junit (and ANT) do their (very incorrectly coded, I am afraid http://discuss.develop.com/archives/wa.exe?A2=ind0302&L=ADVANCED-JAVA&P=R16312&I=-3\) testcase classloading. It will be a high priority issue to address once I am done with the house move mentioned earlier in this forum.
If you are using the offline instrumentation mode (seems like you are according to your post), try the following:
- try forking <junit> (fork="true")
If this does not help, submit a bug report to the tracker that contains your exact <junit> invocation and attach the result of running "ant -debug ...".