我正在尝试调试(在Eclipse上的F11)我继承的java GUI应用程序但是在Eclipse IDE之外应用程序运行正常(减去我需要应用的一个小修复)时,从Eclipse启动时会产生以下异常(F11或Ctrl + F11):
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at com.example.myapp.LoginWindow.buildHibernateConfig(LoginWindow.java:178)
at com.example.myapp.LoginWindow.actionPerformed(LoginWindow.java:141)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at javax.swing.plaf.basic.BasicRootPaneUI$Actions.actionPerformed(BasicRootPaneUI.java:191)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1639)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2859)
at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:267)
at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:216)
at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2936)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2928)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2822)
at java.awt.Component.processEvent(Component.java:6074)
at java.awt.Container.processEvent(Container.java:2039)
at java.awt.Component.dispatchEventImpl(Component.java:4660)
at java.awt.Container.dispatchEventImpl(Container.java:2097)
at java.awt.Component.dispatchEvent(Component.java:4488)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1856)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:722)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1000)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:865)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:686)
at java.awt.Component.dispatchEventImpl(Component.java:4532)
at java.awt.Container.dispatchEventImpl(Container.java:2097)
at java.awt.Window.dispatchEventImpl(Window.java:2489)
at java.awt.Component.dispatchEvent(Component.java:4488)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:668)
at java.awt.EventQueue.access$400(EventQueue.java:81)
at java.awt.EventQueue$2.run(EventQueue.java:627)
at java.awt.EventQueue$2.run(EventQueue.java:625)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:641)
at java.awt.EventQueue$3.run(EventQueue.java:639)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:638)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 47 more
我对此的初步搜索发现the dom4j library may be missing,但将其添加到pom.xml:
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
不解决了问题。
知道为什么我会收到此异常(仅在从Eclipse 启动时)以及如何解决此问题?
BTW,添加saxson
依赖项只是因为在构建时尝试使用the latest dom4j导致了未解析的依赖项。但是自从我降级到dom4j 1.6.1
后,我可以消除撒克逊依赖关系,因此pom.xml文件现在只包含:
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
答案 0 :(得分:2)
兄弟,您需要导入所有jar文件来运行您的程序。这些是运行项目所必需的
POI-3.10-Final.jar
POI-OOXML-3.10-Final.jar
POI-OOXML-架构 - 3.10.jar
的xmlbeans-2.30.jar
答案 1 :(得分:1)
我将转到Eclipse“debug”视图并获取Eclipse用于运行程序的实际命令。 您应该在程序启动后立即暂停该程序,然后在“调试”视图中右键单击SECOND行,然后选择属性。 您将看到一个名为“process properties”的窗口,可以从中复制Eclipse生成的命令来运行程序。 您可以将命令粘贴到终端中,然后查看Java如何解析类路径。通过添加-verbose参数来查看实际加载的罐子。
编辑 - 只是说清楚,当我说“调试视图”时我的意思是
"Main Menu"->"Window"->"Show View"->"Debug"