GWT单元测试 java.lang.NoSuchMethodError: org.mortbay.thread.Timeout

当对GWT项目构建单元测试,第一次用Eclipse Google插件运行test case (Run As -> GWT Junit Test)时,很可能会遇到下面这个错误。

Starting Jetty on port 0
   [WARN] failed org.mortbay.jetty.nio.SelectChannelConnector$1@137742d
java.lang.NoSuchMethodError: org.mortbay.thread.Timeout.<init>(Ljava/lang/Object;)V
	at org.mortbay.io.nio.SelectorManager$SelectSet.<init>(SelectorManager.java:306)
	at org.mortbay.io.nio.SelectorManager.doStart(SelectorManager.java:223)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:303)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at org.mortbay.jetty.Server.doStart(Server.java:233)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:667)
	at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:500)
	at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1055)
	at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:705)
	at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:650)
	at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	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.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
   [WARN] failed [email protected]:0
java.lang.NoSuchMethodError: org.mortbay.thread.Timeout.<init>(Ljava/lang/Object;)V
	at org.mortbay.io.nio.SelectorManager$SelectSet.<init>(SelectorManager.java:306)
	at org.mortbay.io.nio.SelectorManager.doStart(SelectorManager.java:223)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:303)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at org.mortbay.jetty.Server.doStart(Server.java:233)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:667)
	at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:500)
	at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1055)
	at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:705)
	at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:650)
	at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	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.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
   [WARN] failed Server@a60593
java.lang.NoSuchMethodError: org.mortbay.thread.Timeout.<init>(Ljava/lang/Object;)V
	at org.mortbay.io.nio.SelectorManager$SelectSet.<init>(SelectorManager.java:306)
	at org.mortbay.io.nio.SelectorManager.doStart(SelectorManager.java:223)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:303)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at org.mortbay.jetty.Server.doStart(Server.java:233)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
	at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:667)
	at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:500)
	at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1055)
	at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:705)
	at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:650)
	at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	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.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


这个错误是因为GWT库和Google AppEngine库都包含org.morbay包,所以会产生class path冲突。

最简单直接的解决方法是进入该项目的属性(Properties)-> Java Build Path -> Order and Export,选中GWT SDK,然后点击旁边的Top按钮,把GWT SDK移动到最上面(先于Google AppEngine执行)即可。


GWT单元测试 java.lang.NoSuchMethodError: org.mortbay.thread.Timeout_第1张图片


你可能感兴趣的:(GWT单元测试 java.lang.NoSuchMethodError: org.mortbay.thread.Timeout)