jGleitz / JUnit-KIT

Tests for the Tasks of the Programming Lecture for first semesters at the Karlsruhe Institute for Technology, winter semester 14/15. Among the tests themselves, this repository contains helpfull classes for testing unknown implementations.
GNU General Public License v2.0
7 stars 7 forks source link

NoClassDefFoundError: Could not initialize class test.framework.Terminal in all tests #38

Closed RomanLangrehr closed 9 years ago

RomanLangrehr commented 9 years ago

On my computer all tests fail because of an NoClassDefFoundError: Could not initialize class test.framework.Terminal.

jGleitz commented 9 years ago

I booted to Windows and now get the same error. I'm looking into it in the moment.

jGleitz commented 9 years ago

@RomanLan: Does your first failing method (red cross) have an error like this, too?:

java.lang.ExceptionInInitializerError
    at test.framework.Terminal.<clinit>(Terminal.java:77)
    at test.TestObject.run(TestObject.java:634)
    at test.TestObject.runStaticVoid(TestObject.java:461)
    at test.TestObject.runStaticVoid(TestObject.java:474)
    at test.InteractiveConsoleTest.noOutputTest(InteractiveConsoleTest.java:352)
    at test.InteractiveConsoleTest.noOutputTest(InteractiveConsoleTest.java:336)
    at final1.subtests.ValidInputFileTest.taskSheetInputFileTest(ValidInputFileTest.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
Caused by: test.framework.FrameworkException: Your System does not provide a Java Compiler and is not Windows – we're all out of ideas!

This is a serious issue. But we'd like to help solve this!
Please report what happened on GitHub. Create a new issue at:
https://github.com/jGleitz/JUnit-KIT/issues
    at test.mocking.MockCompiler.getJavaCompiler(MockCompiler.java:153)
    at test.mocking.MockCompiler.<clinit>(MockCompiler.java:31)
    ... 17 more
RomanLangrehr commented 9 years ago

@jGleitz Yes

jGleitz commented 9 years ago

@RomanLan: Does c3834fe solve this for you, too?

MartinLoeper commented 9 years ago

@jGleitz I still get an error message running the tests on Windows, too.

java.lang.NoClassDefFoundError: Could not initialize class test.framework.Terminal
    at test.TestObject.run(TestObject.java:634)
    at test.TestObject.runStaticVoid(TestObject.java:461)
    at test.TestObject.runStaticVoid(TestObject.java:474)
    at test.InteractiveConsoleTest.errorTest(InteractiveConsoleTest.java:145)
    at final1.subtests.RecommendationSubtest.exitTest(RecommendationSubtest.java:58)
    at final1.subtests.RecommendationSubtest.exitTest(RecommendationSubtest.java:44)
    at final1.subtests.InvalidInputFileTest.predecessorOfCircleTest(InvalidInputFileTest.java:223)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)

java.lang.NoClassDefFoundError: Could not initialize class test.framework.Terminal
    at test.TestObject.run(TestObject.java:634)
    at test.TestObject.runStaticVoid(TestObject.java:461)
    at test.TestObject.runStaticVoid(TestObject.java:474)
    at test.InteractiveConsoleTest.errorTest(InteractiveConsoleTest.java:145)
    at final1.subtests.RecommendationSubtest.exitTest(RecommendationSubtest.java:58)
    at final1.subtests.RecommendationSubtest.exitTest(RecommendationSubtest.java:44)
    at final1.subtests.InvalidInputFileTest.predecessorOfCircleTest(InvalidInputFileTest.java:223)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
RomanLangrehr commented 9 years ago

On my computer it seems to work now.

jGleitz commented 9 years ago

@RomanLan: Glad to hear!

jGleitz commented 9 years ago

@MartinLoeper: Even with c3834fe? If yes, is there any error message (except for incomplete) that is different from this one?

MartinLoeper commented 9 years ago

@jGleitz I installed the latest testsuite minutes ago and receive the NoClassDefFoundError for every test. Only for incomplete the error does not happen. Every exception stack trace does reference test.TestObject.run(TestObject.java:634) as the cause.

jGleitz commented 9 years ago

Screw it. I cannot reproduce that. Could you please:

jGleitz commented 9 years ago

Better, copy anything from elementData to the last element and paste it here. Mine looks like this:

elementData Object[160]  (id=246)   
    [0...99]    
        [0] Class<T> (org.eclipse.jdt.internal.junit.runner.MessageSender) (id=248) 
        [1] Class<T> (org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees) (id=249)  
        [2] Class<T> (org.eclipse.jdt.internal.junit.runner.RemoteTestRunner) (id=250)  
        [3] Class<T> (org.eclipse.jdt.internal.junit.runner.IClassifiesThrowables) (id=251) 
        [4] Class<T> (org.eclipse.jdt.internal.junit.runner.IListensToTestExecutions) (id=255)  
        [5] Class<T> (org.eclipse.jdt.internal.junit.runner.FirstRunExecutionListener) (id=256) 
        [6] Class<T> (org.eclipse.jdt.internal.junit.runner.RerunExecutionListener) (id=257)    
        [7] Class<T> (org.eclipse.jdt.internal.junit.runner.RemoteTestRunner$RerunRequest) (id=258) 
        [8] Class<T> (org.eclipse.jdt.internal.junit.runner.TestExecution) (id=259) 
        [9] Class<T> (org.eclipse.jdt.internal.junit.runner.ITestIdentifier) (id=260)   
        [10]    Class<T> (org.eclipse.jdt.internal.junit.runner.ITestLoader) (id=261)   
        [11]    Class<T> (org.eclipse.jdt.internal.junit.runner.TestIdMap) (id=262) 
        [12]    Class<T> (org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader) (id=263) 
        [13]    Class<T> (org.eclipse.jdt.internal.junit.runner.ITestReference) (id=264)    
        [14]    Class<T> (org.eclipse.jdt.internal.junit.runner.RemoteTestRunner$ReaderThread) (id=16)  
        [15]    Class<T> (org.eclipse.jdt.internal.junit.runner.DefaultClassifier) (id=265) 
        [16]    Class<T> (final1.RecommendationTest) (id=266)   
        [17]    Class<T> (org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference) (id=267)  
        [18]    Class<T> (org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference) (id=268) 
        [19]    Class<T> (org.junit.runner.notification.StoppedByUserException) (id=269)    
        [20]    Class<T> (org.junit.runner.notification.RunListener) (id=270)   
        [21]    Class<T> (org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener) (id=271)   
        [22]    Class<T> (org.eclipse.jdt.internal.junit.runner.IStopListener) (id=272) 
        [23]    Class<T> (org.junit.runner.Request) (id=273)    
        [24]    Class<T> (org.junit.runner.Describable) (id=274)    
        [25]    Class<T> (org.junit.runner.Runner) (id=275) 
        [26]    Class<T> (org.junit.internal.runners.ErrorReportingRunner) (id=276) 
        [27]    Class<T> (org.junit.internal.requests.FilterRequest) (id=277)   
        [28]    Class<T> (org.junit.runner.Request$1) (id=278)  
        [29]    Class<T> (org.junit.internal.requests.SortingRequest) (id=279)  
        [30]    Class<T> (org.junit.internal.requests.ClassRequest) (id=280)    
        [31]    Class<T> (org.junit.runners.model.InitializationError) (id=281) 
        [32]    Class<T> (org.junit.runners.model.RunnerBuilder) (id=282)   
        [33]    Class<T> (org.junit.internal.builders.AllDefaultPossibilitiesBuilder) (id=283)  
        [34]    Class<T> (org.junit.internal.builders.SuiteMethodBuilder) (id=284)  
        [35]    Class<T> (org.junit.internal.builders.NullBuilder) (id=285) 
        [36]    Class<T> (org.junit.internal.builders.IgnoredBuilder) (id=286)  
        [37]    Class<T> (org.junit.internal.builders.IgnoredClassRunner) (id=287)  
        [38]    Class<T> (org.junit.internal.builders.AnnotatedBuilder) (id=288)    
        [39]    Class<T> (org.junit.runner.manipulation.Filterable) (id=289)    
        [40]    Class<T> (org.junit.runner.manipulation.Sortable) (id=290)  
        [41]    Class<T> (org.junit.internal.runners.JUnit38ClassRunner) (id=291)   
        [42]    Class<T> (org.junit.internal.runners.SuiteMethod) (id=292)  
        [43]    Class<T> (org.junit.internal.builders.JUnit3Builder) (id=293)   
        [44]    Class<T> (org.junit.internal.builders.JUnit4Builder) (id=294)   
        [45]    Class<T> (org.junit.runners.ParentRunner) (id=76)   
        [46]    Class<T> (org.junit.runners.BlockJUnit4ClassRunner) (id=295)    
        [47]    Class<T> (org.junit.Ignore) (id=296)    
        [48]    Class<T> (org.junit.runner.RunWith) (id=297)    
        [49]    Class<T> (org.junit.runners.Suite) (id=298) 
        [50]    Class<T> (com.sun.proxy.$Proxy2) (id=299)   
        [51]    Class<T> (org.junit.runners.Suite$SuiteClasses) (id=300)    
        [52]    Class<T> (test.InteractiveConsoleTest) (id=22)  
        [53]    Class<T> (final1.subtests.RecommendationSubtest) (id=52)    
        [54]    Class<T> (final1.subtests.ValidInputFileTest) (id=37)   
        [55]    Class<T> (final1.subtests.InvalidInputFileTest) (id=53) 
        [56]    Class<T> (final1.subtests.ValidNodesCommandTest) (id=139)   
        [57]    Class<T> (com.sun.proxy.$Proxy3) (id=301)   
        [58]    Class<T> (org.junit.runners.model.Statement) (id=302)   
        [59]    Class<T> (org.junit.internal.runners.statements.RunBefores) (id=29) 
        [60]    Class<T> (org.junit.rules.RunRules) (id=303)    
        [61]    Class<T> (org.junit.internal.runners.statements.RunAfters) (id=304) 
        [62]    Class<T> (org.hamcrest.SelfDescribing) (id=305) 
        [63]    Class<T> (org.junit.internal.AssumptionViolatedException) (id=306)  
        [64]    Class<T> (org.junit.runners.ParentRunner$2) (id=307)    
        [65]    Class<T> (org.junit.runner.manipulation.NoTestsRemainException) (id=308)    
        [66]    Class<T> (org.junit.runners.model.RunnerScheduler) (id=309) 
        [67]    Class<T> (junit.framework.Test) (id=310)    
        [68]    Class<T> (junit.framework.Assert) (id=311)  
        [69]    Class<T> (junit.framework.TestCase) (id=312)    
        [70]    Class<T> (org.junit.internal.runners.statements.InvokeMethod) (id=54)   
        [71]    Class<T> (org.junit.internal.runners.statements.Fail) (id=313)  
        [72]    Class<T> (org.junit.internal.runners.statements.ExpectException) (id=314)   
        [73]    Class<T> (org.junit.internal.runners.statements.FailOnTimeout) (id=75)  
        [74]    Class<T> (org.junit.runner.manipulation.Sorter) (id=315)    
        [75]    Class<T> (org.junit.runner.manipulation.Sorter$1) (id=316)  
        [76]    Class<T> (org.junit.runners.ParentRunner$1) (id=317)    
        [77]    Class<T> (org.junit.runners.model.TestClass) (id=318)   
        [78]    Class<T> (org.junit.runners.model.FrameworkMember) (id=319) 
        [79]    Class<T> (org.junit.runners.model.FrameworkMethod) (id=28)  
        [80]    Class<T> (org.junit.runners.model.FrameworkField) (id=320)  
        [81]    Class<T> (org.junit.internal.MethodSorter) (id=321) 
        [82]    Class<T> (org.junit.internal.MethodSorter$1) (id=322)   
        [83]    Class<T> (org.junit.internal.MethodSorter$2) (id=323)   
        [84]    Class<T> (org.junit.FixMethodOrder) (id=324)    
        [85]    Class<T> (org.junit.Test) (id=325)  
        [86]    Class<T> (org.junit.Test$None) (id=326) 
        [87]    Class<T> (com.sun.proxy.$Proxy4) (id=327)   
        [88]    Class<T> (org.junit.Before) (id=328)    
        [89]    Class<T> (org.junit.BeforeClass) (id=329)   
        [90]    Class<T> (org.hamcrest.Matcher) (id=330)    
        [91]    Class<T> (com.sun.proxy.$Proxy6) (id=331)   
        [92]    Class<T> (org.junit.rules.TestRule) (id=332)    
        [93]    Class<T> (org.junit.rules.Timeout) (id=333) 
        [94]    Class<T> (org.junit.Rule) (id=334)  
        [95]    Class<T> (com.sun.proxy.$Proxy7) (id=335)   
        [96]    Class<T> (org.junit.AfterClass) (id=336)    
        [97]    Class<T> (org.junit.internal.runners.rules.RuleFieldValidator) (id=337) 
        [98]    Class<T> (org.junit.ClassRule) (id=338) 
        [99]    Class<T> (org.junit.Assert) (id=49) 
    [100...159] 
        [100]   Class<T> (org.junit.ComparisonFailure) (id=350) 
        [101]   Class<T> (org.junit.After) (id=351) 
        [102]   Class<T> (org.junit.rules.MethodRule) (id=352)  
        [103]   Class<T> (org.junit.runner.Description) (id=353)    
        [104]   Class<T> (org.eclipse.jdt.internal.junit4.runner.JUnit4Identifier) (id=354) 
        [105]   Class<T> (org.junit.runner.notification.RunNotifier) (id=355)   
        [106]   Class<T> (org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference$1) (id=356)    
        [107]   Class<T> (org.junit.runner.Result) (id=357) 
        [108]   Class<T> (org.junit.runner.Result$Listener) (id=358)    
        [109]   Class<T> (org.junit.runner.notification.RunNotifier$SafeNotifier) (id=359)  
        [110]   Class<T> (org.junit.runner.notification.RunNotifier$1) (id=360) 
        [111]   Class<T> (org.junit.internal.runners.model.EachTestNotifier) (id=361)   
        [112]   Class<T> (org.junit.runners.ParentRunner$3) (id=362)    
        [113]   Class<T> (org.junit.internal.runners.model.ReflectiveCallable) (id=27)  
        [114]   Class<T> (org.junit.runners.BlockJUnit4ClassRunner$1) (id=363)  
        [115]   Class<T> (org.junit.runner.notification.RunNotifier$3) (id=364) 
        [116]   Class<T> (org.junit.internal.runners.statements.FailOnTimeout$StatementThread) (id=18)  
        [117]   Class<T> (org.junit.runners.model.FrameworkMethod$1) (id=26)    
        [118]   Class<T> (test.SystemExitStatus) (id=365)   
        [119]   Class<T> (test.TestObject) (id=21)  
        [120]   Class<T> (test.framework.NoExitSecurityManager) (id=366)    
        [121]   Class<T> (test.TestMethodException) (id=367)    
        [122]   Class<T> (test.framework.TestClassLoader) (id=19)   
        [123]   Class<T> (org.junit.runners.model.MultipleFailureException) (id=368)    
        [124]   Class<T> (org.junit.runner.notification.Failure) (id=369)   
        [125]   Class<T> (org.junit.runner.notification.RunNotifier$4) (id=370) 
        [126]   Class<T> (junit.framework.AssertionFailedError) (id=371)    
        [127]   Class<T> (junit.framework.ComparisonFailure) (id=372)   
        [128]   Class<T> (org.eclipse.jdt.internal.junit.runner.TestReferenceFailure) (id=373)  
        [129]   Class<T> (org.junit.runner.notification.RunNotifier$7) (id=374) 
        [130]   Class<T> (test.Input) (id=375)  
        [131]   Class<T> (test.framework.ExitException) (id=376)    
        [132]   Class<T> (test.framework.Terminal) (id=72)  
        [133]   Class<T> (test.framework.FrameworkException) (id=377)   
        [134]   Class<T> (test.mocking.MockerJavaSourceFile) (id=378)   
        [135]   Class<T> (test.mocking.MockCompiler) (id=379)   
        [136]   Class<T> (test.mocking.MockerJavaClassFile) (id=380)    
        [137]   Class<T> (test.mocking.SerializableByteArrayOutputStream) (id=381)  
        [138]   Class<T> (test.mocking.MockCompiler$1) (id=382) 
        [139]   Class<T> (test.mocking.MockCompilerFileManager) (id=383)    
        [140]   Class<T> (test.framework.Terminal$Method) (id=384)  
        [141]   Class<T> (org.hamcrest.CoreMatchers) (id=385)   
        [142]   Class<T> (org.hamcrest.BaseMatcher) (id=386)    
        [143]   Class<T> (org.hamcrest.core.Is) (id=387)    
        [144]   Class<T> (org.hamcrest.core.IsEqual) (id=388)   
        [145]   Class<T> (org.junit.runner.notification.RunNotifier$2) (id=389) 
MartinLoeper commented 9 years ago

I do not get it... When I try to examine elementData, I get: [null, null, null, null, null, null, null, null, null, null].

jGleitz commented 9 years ago

Oh wonderful. What exact system are you running? OS & Java Version.

MartinLoeper commented 9 years ago

Win7 with Java 8.0_25.

jGleitz commented 9 years ago

@MartinLoeper Do you use Google Hangouts or another software supporting screen sharing? It would be nice to debug this on your machine, if you'd allow me to.

MartinLoeper commented 9 years ago

yes, ok, let's do it

MartinLoeper commented 9 years ago

Allright, I finally solved the error! It was located in MockCompiler.java (l.116). The default Java installation folder is "C:\Program Files (x86)\Java" in my case.

jGleitz commented 9 years ago

Oh, you have 32bit. Didn't think of it. I'll fix this.

Nevertheless, a error message

Your system does not provide a Java Compiler. It's Windows but we can't find your Java installation!

should be printed!

MartinLoeper commented 9 years ago

Yes, it was printed. I did not recognize it the first time. Sorry for that.

jGleitz commented 9 years ago

@MartinLoeper Please check if #58 solves this for you!