我创建了一个运行junit测试的applet。 当我从Eclipse运行applet时,一切正常。 当我尝试将其嵌入HTML时,我正确地获得了UI,但是当我单击“确定”开始执行测试时,我收到以下错误。
Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener
at lefty.GuiContainer$1.actionPerformed(GuiContainer.java:32)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 36 more
我已将所有类加上所有externan jar文件包含在一个.jar中,并且当我从HTML调用applet时使用它。 我的HTML非常简单:
<html>
<title> Performance App </title>
<body>
<h2> Applet... </h2>
<applet code=lefty.AppletSetup.class width="200" height="200" archive="performanceApp.jar">
</applet>
</body>
</htmL>
另外我必须提到我的一个类扩展了RunListener但是我已经将junit.jar包含在我的classpath和最后一个jar中。
答案 0 :(得分:1)
另外我必须提到我的一个类扩展了RunListener但是我 已经将junit.jar包含在我的classpath和最后一个jar中。
有些观点
C)
引起:java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener这一行表示该类真的不见了,所以它是在项目jar中吗?
我想你不应该用单元测试代码部署applet;仅仅因为所有单元测试都是针对IDE applet模拟运行的;所以尝试在没有junit的情况下部署它
祝你好运