ClassNotFoundException:org.eclipse.xtext.junit_2.4.3.v201309030823找不到junit.framework.TestCase [英] ClassNotFoundException: junit.framework.TestCase cannot be found by org.eclipse.xtext.junit_2.4.3.v201309030823

查看:591
本文介绍了ClassNotFoundException:org.eclipse.xtext.junit_2.4.3.v201309030823找不到junit.framework.TestCase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这个错误感到困惑:

I'm puzzled by this error:

java.lang.NoClassDefFoundError: junit/framework/TestCase
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638)
...
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
    at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
...
Caused by: java.lang.ClassNotFoundException: junit.framework.TestCase cannot be found by org.eclipse.xtext.junit_2.4.3.v201309030823
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 78 more

异常发生当我为我的Xtext DSL运行测试作为插件测试时(即在内部启动新的Eclipse平台时)。这种情况发生在之后我的任何代码执行。

The exception happens when I run the tests for my Xtext DSL as plugin tests (i.e. when a new Eclipse platform is started internally). This happens before any of my code is executed.

当我查看插件依赖项时,我可以看到 org.junit_4.11.0.v201303080030.jar 在类路径上,我也看到 /.../ workspace / .metadata / .plugins / org.eclipse.pde.core /.external_libraries/org.junit_4.11.0.v201303080030/junit.jar

When I look at the plugin dependencies, I can see that org.junit_4.11.0.v201303080030.jar is on the classpath and I also see /.../workspace/.metadata/.plugins/org.eclipse.pde.core/.external_libraries/org.junit_4.11.0.v201303080030/junit.jar

所以OSGis绝对应该能够解决这种依赖。

So OSGis should definitely be able to resolve this dependency.

Xtext 2.4.3是否可以与JUnit 4.11一起使用,还是必须将我的Eclipse安装降级为JUnit 4.10?

Does Xtext 2.4.3 work with JUnit 4.11 or do I have to downgrade my Eclipse install to JUnit 4.10?

推荐答案

两分

第一

检查项目属性 - > Java构建路径 - >库(选项卡)。 JUnit应该在那里,虽然这通常会出现在构建中。

Check your Project Properties->Java Build Path->Libraries (tab). JUnit should be there although this usually will show up in the build.

检查项目的运行配置 - > JUnit->类路径(选项卡) )。 JUnit应该在您项目的用户条目下。

Check you Project's Run Configurations->JUnit->Classpath (tab). JUnit should be under User Entries for your project.

第二

检查你有以下插件

org.eclipse.xtext.xbase.junit
org.junit (3.8.2)
org.junit (4.8.2)

这让我走上了正确的轨道。要修复错误,请确保在目标平台

This got me on the right track. To fix the error make sure you have org.junit 3.8 in the target platform!

说明:上述错误意味着Eclipse本身无法启动。似乎JUnit运行器依赖于JUnit 3.8。它不会被使用但没有它,整个平台都无法初始化。

Explanation: The error above means that Eclipse itself couldn't start. It seems that the JUnit runner has a dependency on JUnit 3.8. It won't be used but without it, the whole platform can't be initialized.

通过查看堆栈跟踪,您可以看到是否有同样的问题:它是否包含 RemotePluginTestRunner.main

You can see whether you have the same problem by looking at the stack trace: Does it contain RemotePluginTestRunner.main?

要修复错误,请将org.junit 3.8软件包添加到目标平台。

To fix the error, add the org.junit 3.8 bundle to your target platform.

这篇关于ClassNotFoundException:org.eclipse.xtext.junit_2.4.3.v201309030823找不到junit.framework.TestCase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆