java.lang.NoClassDefFoundError:org/apache/poi/xssf/usermodel/XSSFWorkbook [英] java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook

查看:208
本文介绍了java.lang.NoClassDefFoundError:org/apache/poi/xssf/usermodel/XSSFWorkbook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个异常,但是我不明白那里发生了什么.

I was getting this exception but I am not able to understand what is happening there.

由于在编译时,我的班级可以访问apache POI类,但是在运行时,我的班级抛出了他找不到的异常

Because on compilation time my class able access apache POI classes but on runtime my classes throws exception that he is not able find

org.apache.poi.xssf.usermodel.XSSFWorkbook .

到目前为止,无论网上提供了什么解决方案,我都尝试了一切,但仍不了解我所缺少的内容.

Till now whatever solution is provided on net I have tried everything but not understanding what I am missing.

奇怪的是,在我朋友的日食上运行的是相同的代码和相同的Apache POI库.我们都有相同的项目.不明白那里发生了什么.

And weird thing is same code and same Apache POI library working on my friend's eclipse. We both have identical projects. Don't understand what is going on there.

我检查了我要引用库的所有文件夹的访问权限.

I checked all folder's access where I am referring libraries.

如有任何建议,请分享.

Please share if you have any suggestion.

我遇到以下异常.

!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$2(ActionContributionItem.java:511)
    at org.eclipse.jface.action.ActionContributionItem$5.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$9.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$5.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.MF as follow

    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如下

build.properties as follow

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               icons/,\
               OSGI-INF/l10n/message.properties

推荐答案

插件只能访问捆绑包类路径中包含的其他插件或该插件中包含的jar中的类.设置Java Build Path属性无法正确配置插件.

A plugin can only access classes in other plugins or in jars included in the plugin which are included in the bundle class path. Setting the Java Build Path properties does not configure the plugin correctly.

将所有需要的jar添加到插件中,通常将它们放在"lib"目录中.

Add all the jars you need to the plugin, usually these are put in a 'lib' directory.

更新build.properties以在"bin.includes"部分中包含这些jar.例如:

Update the build.properties to include these jars in the 'bin.includes' section. For example:

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,这只是我的一个项目中的一个示例).

Here I have 3 jars in a lib directory (these are not the POI jars, this is just an example from one of my projects).

更新MANIFEST.MF并设置 Bundle-Classpath 以包括罐子.您可以在类路径"部分运行时"选项卡的MANIFEST.MF编辑器中执行此操作(使用列表右侧的添加..."按钮,然后在插件中选择库).确保将条目保留为.".您的MANIFEST.MF应该最终包含"Bundle-Classpath"条目,如下所示:

Update the MANIFEST.MF and set the Bundle-Classpath to include the jars. You can do this in the MANIFEST.MF editor in the 'Runtime' tab in the 'Classpath' section (use the Add... button to the right of the list and choose the libraries in the plugin). Be sure to leave the entry for '.'. Your MANIFEST.MF should end up containing a `Bundle-Classpath' entry like this:

Bundle-ClassPath: .,
 lib/jogg-0.0.7.jar,
 lib/jorbis-0.0.15.jar,
 lib/vorbisspi1.0.2.jar

这篇关于java.lang.NoClassDefFoundError:org/apache/poi/xssf/usermodel/XSSFWorkbook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆