java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
我遇到了这个异常,但我无法理解那里发生了什么。
因为在编译时我的 class 能够访问 apache POI classes 但在运行时我的 classes 抛出他无法找到的异常
org.apache.poi.xssf.usermodel.XSSFWorkbook
。
到目前为止,无论网上提供什么解决方案,我都试过了,但不明白我错过了什么。
奇怪的是相同的代码和相同的 Apache POI 库在我朋友的 eclipse 上运行。我们都有相同的项目。不明白那里发生了什么。
我检查了我引用库的所有文件夹的访问权限。
有什么建议请分享
我收到以下异常。
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
at com.herzog.pmide.mergedconfigxml.ui.editors.DocumentGenerator.prepareScadaIOListExcel(DocumentGenerator.java:94)
at com.herzog.pmide.mergedconfigxml.ui.editors.DocumentGenerator.scadaIOList(DocumentGenerator.java:77)
at com.herzog.pmide.mergedconfigxml.ui.actions.DocumentGeneratorAction.run(DocumentGeneratorAction.java:47)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem.handleEvent(ActionContributionItem.java:420)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:331)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:331)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at com.herzog.pmide.application.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbook cannot be found by com.herzog.pmide.mergedconfigxml.ui_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
MANIFEST.MF 如下
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: com.herzog.pmide.mergedconfigxml.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.herzog.pmide.mergedconfigxml.ui.Activator
Bundle-Vendor: Example
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.edit.ui,
com.herzog.pmide.machinelib.model.edit,
org.eclipse.ui.forms,
org.eclipse.ui.workbench,
org.eclipse.ui.ide,
com.herzog.pmide.mergedconfigxml.model.edit,
org.eclipse.gef,
com.herzog.pmide.tools.importutility,
com.herzog.pmide.machinelib.model,
org.eclipse.swt,
org.eclipse.emf.query,
com.herzog.pmide.mergedconfigxml.model,
org.eclipse.ui.editors,
org.eclipse.emf.validation,
org.eclipse.emf.validation.ui,
org.slf4j.api,
org.junit,
org.eclipse.emf.compare,
org.eclipse.emf.compare.edit,
org.eclipse.emf.compare.ide.ui,
org.eclipse.compare,
org.apache.commons.io,
org.eclipse.core.filesystem,
de.vonloesch.pdf4Eclipse,
de.vonloesch.pdf4eclipse.help,
com.herzog.pmide.routingline.model
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Export-Package: com.herzog.pmide.mergedconfigxml.ui,
com.herzog.pmide.mergedconfigxml.ui.editors.unitconfig,
com.herzog.pmide.mergedconfigxml.ui.views
Bundle-Localization: OSGI-INF/l10n/message
build.properties如下
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/,\
OSGI-INF/l10n/message.properties
插件只能访问其他插件中的 classes 或包含在包 class 路径中的插件中的 jars。设置 Java 构建路径属性不会正确配置插件。
将你需要的所有 jar 添加到插件中,通常这些都放在 'lib' 目录中。
更新 build.properties 以将这些 jar 包含在 'bin.includes' 部分中。例如:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
plugin.xml,\
lib/,\
lib/jogg-0.0.7.jar,\
lib/jorbis-0.0.15.jar,\
lib/vorbisspi1.0.2.jar
我在 lib 目录中有 3 个 jar(这些不是 POI jar,这只是我的一个项目中的一个示例)。
更新 MANIFEST.MF 并设置 Bundle-Classpath
以包含 jars。您可以在 'Classpath' 部分的 'Runtime' 选项卡中的 MANIFEST.MF 编辑器中执行此操作(使用列表右侧的添加...按钮并选择插件中的库) .请务必保留“.”条目。您的 MANIFEST.MF 应该最终包含一个像这样的“Bundle-Classpath”条目:
Bundle-ClassPath: .,
lib/jogg-0.0.7.jar,
lib/jorbis-0.0.15.jar,
lib/vorbisspi1.0.2.jar
我遇到了这个异常,但我无法理解那里发生了什么。
因为在编译时我的 class 能够访问 apache POI classes 但在运行时我的 classes 抛出他无法找到的异常
org.apache.poi.xssf.usermodel.XSSFWorkbook
。
到目前为止,无论网上提供什么解决方案,我都试过了,但不明白我错过了什么。
奇怪的是相同的代码和相同的 Apache POI 库在我朋友的 eclipse 上运行。我们都有相同的项目。不明白那里发生了什么。
我检查了我引用库的所有文件夹的访问权限。
有什么建议请分享
我收到以下异常。
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
at com.herzog.pmide.mergedconfigxml.ui.editors.DocumentGenerator.prepareScadaIOListExcel(DocumentGenerator.java:94)
at com.herzog.pmide.mergedconfigxml.ui.editors.DocumentGenerator.scadaIOList(DocumentGenerator.java:77)
at com.herzog.pmide.mergedconfigxml.ui.actions.DocumentGeneratorAction.run(DocumentGeneratorAction.java:47)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem.handleEvent(ActionContributionItem.java:420)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:331)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:331)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at com.herzog.pmide.application.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbook cannot be found by com.herzog.pmide.mergedconfigxml.ui_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
MANIFEST.MF 如下
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: com.herzog.pmide.mergedconfigxml.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.herzog.pmide.mergedconfigxml.ui.Activator
Bundle-Vendor: Example
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.edit.ui,
com.herzog.pmide.machinelib.model.edit,
org.eclipse.ui.forms,
org.eclipse.ui.workbench,
org.eclipse.ui.ide,
com.herzog.pmide.mergedconfigxml.model.edit,
org.eclipse.gef,
com.herzog.pmide.tools.importutility,
com.herzog.pmide.machinelib.model,
org.eclipse.swt,
org.eclipse.emf.query,
com.herzog.pmide.mergedconfigxml.model,
org.eclipse.ui.editors,
org.eclipse.emf.validation,
org.eclipse.emf.validation.ui,
org.slf4j.api,
org.junit,
org.eclipse.emf.compare,
org.eclipse.emf.compare.edit,
org.eclipse.emf.compare.ide.ui,
org.eclipse.compare,
org.apache.commons.io,
org.eclipse.core.filesystem,
de.vonloesch.pdf4Eclipse,
de.vonloesch.pdf4eclipse.help,
com.herzog.pmide.routingline.model
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Export-Package: com.herzog.pmide.mergedconfigxml.ui,
com.herzog.pmide.mergedconfigxml.ui.editors.unitconfig,
com.herzog.pmide.mergedconfigxml.ui.views
Bundle-Localization: OSGI-INF/l10n/message
build.properties如下
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/,\
OSGI-INF/l10n/message.properties
插件只能访问其他插件中的 classes 或包含在包 class 路径中的插件中的 jars。设置 Java 构建路径属性不会正确配置插件。
将你需要的所有 jar 添加到插件中,通常这些都放在 'lib' 目录中。
更新 build.properties 以将这些 jar 包含在 'bin.includes' 部分中。例如:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
plugin.xml,\
lib/,\
lib/jogg-0.0.7.jar,\
lib/jorbis-0.0.15.jar,\
lib/vorbisspi1.0.2.jar
我在 lib 目录中有 3 个 jar(这些不是 POI jar,这只是我的一个项目中的一个示例)。
更新 MANIFEST.MF 并设置 Bundle-Classpath
以包含 jars。您可以在 'Classpath' 部分的 'Runtime' 选项卡中的 MANIFEST.MF 编辑器中执行此操作(使用列表右侧的添加...按钮并选择插件中的库) .请务必保留“.”条目。您的 MANIFEST.MF 应该最终包含一个像这样的“Bundle-Classpath”条目:
Bundle-ClassPath: .,
lib/jogg-0.0.7.jar,
lib/jorbis-0.0.15.jar,
lib/vorbisspi1.0.2.jar