[ http://jira.codehaus.org/browse/SUREFIRE-33?page=comments#action_59643 ]
Jerome Lacoste commented on SUREFIRE-33: ---------------------------------------- I don't have a snippet of code right now, but it should be very easy to reproduce. If I recall, my test case was using Spring which was itself trying to load a class (defined in my applicationContext.xml), class that wasn't in the test classpath. The Surefire code only handles Exceptions. The main problem is that Errors that occur because of reflection to instanciate one test class should not kill the full test battery. http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object[]) Every use of reflection in Surefire should be analyzed to see if they can create such problems. > java.lang.ExceptionInInitializerError in TestCase constructor kills surefire > without letting any log > ---------------------------------------------------------------------------------------------------- > > Key: SUREFIRE-33 > URL: http://jira.codehaus.org/browse/SUREFIRE-33 > Project: surefire > Type: Bug > Environment: maven 2.0.2 > surefire 1.5.3-SNAPSHOT > Reporter: Jerome Lacoste > Assignee: Jason van Zyl > Priority: Critical > Fix For: 1.5.3 > > > In my case the Error is caused by Spring raising a > java.lang.NoClassDefFoundError. > This is problematic in particular when surefire is forked, there is no output > displayed. > Here's the relevant stack trace: > java.lang.ExceptionInInitializerError > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at > org.apache.maven.surefire.battery.JUnitBattery.processTestClass(JUnitBattery.java:130) > at > org.apache.maven.surefire.battery.JUnitBattery.<init>(JUnitBattery.java:81) > at > org.apache.maven.surefire.SurefireUtils.instantiateBattery(SurefireUtils.java:63) > at > org.apache.maven.surefire.Surefire.instantiateBatteries(Surefire.java:262) > at org.apache.maven.surefire.Surefire.run(Surefire.java:140) > at org.apache.maven.surefire.Surefire.run(Surefire.java:87) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at > org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:305) > at > org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:221) > at > org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:368) > at > org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:415) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:531) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:472) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270) > at > org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322) > at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115) > at org.apache.maven.cli.MavenCli.main(MavenCli.java:249) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > And the message that appears when surefire is not forked. > > RUN ABORTED > java.lang.ExceptionInInitializerError > org.apache.maven.surefire.Runner > An exception or error caused a run to abort. > null > > Results : > [surefire] Tests run: 0, Failures: 0, Errors: 1 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira