在Eclipse和IntelliJ中运行ispec测试用例时,我得到了上述错误消息(java.lang.UnsatisfiedLinkError)。
我已经安装了sun/oracle JDK 1.7 .
错误的完整报告是
> Exception in thread "main" java.lang.UnsatisfiedLinkError: > sun.awt.motif.MToolkit.init(Ljava/lang/String;)V at > sun.awt.motif.MToolkit.init(Native Method) at > sun.awt.motif.MToolkit.<init>(MToolkit.java:146) at > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.lang.reflect.Constructor.newInstance(Constructor.java:525) > at java.lang.Class.newInstance0(Class.java:372) at > java.lang.Class.newInstance(Class.java:325) at > org.uispec4j.interception.toolkit.UISpecToolkit.buildUnderlyingToolkit(UISpecToolkit.java:128) > at > org.uispec4j.interception.toolkit.UISpecToolkit.setUp(UISpecToolkit.java:39) > at > org.uispec4j.interception.toolkit.UISpecToolkit.<init>(UISpecToolkit.java:24) > at org.uispec4j.UISpec4J.initToolkit(UISpec4J.java:39) at > org.uispec4j.UISpec4J.init(UISpec4J.java:31) at > org.uispec4j.UISpecTestCase.<clinit>(UISpecTestCase.java:31) at > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.lang.reflect.Constructor.newInstance(Constructor.java:525) > at junit.framework.TestSuite.createTest(TestSuite.java:131) at > junit.framework.TestSuite.addTestMethod(TestSuite.java:114) at > junit.framework.TestSuite.<init>(TestSuite.java:75) at > com.intellij.junit3.TestRunnerUtil.createClassOrMethodSuite(TestRunnerUtil.java:140) > at > com.intellij.junit3.TestRunnerUtil.getTestSuite(TestRunnerUtil.java:79) > at > com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:50) > at > com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) > at > com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) at > com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) > > Process finished with exit code 1
如果有人遇到过同样的问题,请帮助我。
看起来像一个已知的Java Bug: 6996291。
这个问题似乎是由 usispec 在Linux上显式加载sun.awt.motif.MToolkit
引起的,而这个工具包在JDK 1.7中不再可用。查看是否有办法在ispec配置中禁用它或将问题报告给开发人员。
作为一种解决方案,您可以使用Oracle JDK 1.6.0
我有完全相同的问题,但使用openjdk (Linux Mint下)。删除openjdk并安装sun-java6-jdk(使用Linux-Software-Manager)解决了问题。