奇怪的是“NoClassDefFound”错误 [英] Bizarre "NoClassDefFound" Error

查看:223
本文介绍了奇怪的是“NoClassDefFound”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



情景:




  • Windows 7 64位

  • Lotus Notes(8.5.2)

  • Eclipse Helios

  • Java 6 Update 33 (64位)与JDK 7

  • 为插件项目安装的JRE设置为使用Notes下安装的JVM(即 C:\NotesDev\\目标平台使用上面安装的JRE,并导入 framework\rcp\eclipse framework \shared\eclipse 子文件夹。我可以看到两个文件夹之间共有713个插件可用。

  • 运行配置显示了总共714个插件(其中包括目标平台的713个)和我的)。我可以看到这个列表包括 org.eclipse.swt.win32.win32.x86_3.5.2.v34557f-RCP20100710-0200.jar com .ibm.rcp.swtex.win32_6.2.2.20100729-1241.jar



问题:


  1. 如果我没有在我的构建路径中明确包含两个上述的JAR文件,那么应用程序无法编译(尝试导入 org.eclipse.swt.widgets.Display com.ibm.rcp.swt.swidgets.SToolItem )。

  2. 如果我在构建路径中包含上述的JAR文件,由于 NoClassDefFound 异常,应用程序将编译但不会运行。 li>

问题:


  1. 为什么我需要首先要包括这些文件?它们是工作区的一部分,我没有引用任何其他JAR文件似乎不需要被明确引用。

  2. 为什么运行时失败?我的理解是出现 NoClassDefFound ,因为该类在编译时可用,但不在运行时。但这是发生在同一台机器上。 (我试图在本地进行调试,我甚至标记出来的JAR文件!)

在我看来如果文件列在运行时配置的加载插件选项卡中,我不必明确引用它们。我对此不正确吗? (请客气,我确实不是这个专家。)



提前感谢。



PS值得注意的是,如果我在构建路径中包含文件,我可以看到它们在 MANIFEST.MF .CLASSPATH中都被正确引用文件。



MANIFEST.MF目录

  Manifest-Version:1.0 
Bundle-ManifestVersion:2
Bundle-Name:Plugin
Bundle-SymbolicName:com.satuit.crm.plugin; singleton: = true
Bundle版本:1.0.0.qualifier
Bundle-Activator:com.satuit.crm.plugin.Activator
捆绑供应商:Satuit Technologies,Inc.
要求-Bundle:org.eclipse.ui,
org.eclipse.core.runtime,
org.apache.axis,
org.eclipse.ui; bundle-version =3.4.2 ,
org.eclipse.core.runtime; bundle-version =3.4.0,
org.eclipse.ui.views; bundle-version =3.3.1,
com .ibm.rcp.jfaceex; bundle-version =6.2.2
Bundle-RequiredExecutionEnvironment:JavaSE-1.6
Bundle-ActivationPolicy:lazy
导出包:com.satuit.crm。插件,
com.satuit.crm.plugin.doc ument,
com.satuit.crm.plugin.ui,
com.satuit.crm.webservice.agent
Bundle-ClassPath:。,
/ NotesDev / Notes / framework / rcp / eclipse / plugins / org.eclipse.swt.win32.win32.x86_3.5.2.v3557f-RCP20100710-0200.jar,
/NotesDev/Notes/framework/rcp/eclipse/plugins/com.ibm.rcp .swtex.win32_6.2.2.20100729-1241.jar,
/NotesDev/lib/activation-1.1.1.jar,
/NotesDev/lib/mail.jar,
/ NotesDev / lib / commons-lang3-3.1.jar,
/NotesDev/lib/SatuitCRM_XML_API2.jar

** .CLASSPATH目录**

 <?xml version =1.0encoding =UTF-8?> ; 
< classpath>
< classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINER/>
< classpathentry exported =truekind =conpath =org.eclipse.pde.core.requiredPlugins/>
< classpathentry exports =truekind =libpath =C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.5.2.v3557f -RCP20100710-0200.jar/>
< classpathentry exported =truekind =libpath =C:/NotesDev/Notes/framework/rcp/eclipse/plugins/com.ibm.rcp.swtex.win32_6.2.2.20100729-1241的.jar/>
< classpathentry exports =truekind =libpath =C:/NotesDev/Workspace/lib/commons-lang3-3.1.jar/>
< classpathentry exported =truekind =libpath =C:/NotesDev/Workspace/lib/activation-1.1.1.jar/>
< classpathentry exported =truekind =libpath =C:/NotesDev/Workspace/lib/mail.jar/>
< classpathentry exported =truekind =libpath =C:/NotesDev/Workspace/lib/SatuitCRM_XML_API2.jar/>
< classpathentry exports =truekind =libpath =C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/axispatch.jar />
< classpathentry exports =truekind =libpath =C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/axis.jar />
< classpathentry exported =truekind =libpath =C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/jaxrpc.jar />
< classpathentry exports =truekind =libpath =C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/saaj.jar />
< classpathentry exports =truekind =libpath =C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/wsdl4j-1.5 .1.jar/>
< classpathentry kind =srcpath =src/>
< classpathentry kind =outputpath =bin/>
< / classpath>


解决方案

嗯,事实证明,OSGI清单接受类路径上的绝对路径。惊喜,惊喜。



是否应该是另一个故事。任何人猜测应用程序一旦部署,该做什么。但是运行时和编译时间的错误已经消失了,到目前为止似乎并没有重新出现。



再一次,我们认为事实和实际的事实证明是两个非常不同的东西。


This one really has me stumped.

Scenario:

  • Windows 7 64-bit
  • Lotus Notes (8.5.2)
  • Eclipse Helios
  • Java 6 Update 33 (64-bit) with JDK 7
  • Installed JRE for the plugin project is set to use the JVM installed under Notes (that is, C:\NotesDev\Notes\jvm).
  • Target Platform uses the installed JRE above, and imports the framework\rcp\eclipse and framework\shared\eclipse subfolders on the Locations tab. I can see that there are a total of 713 plugins available between the two folders.
  • The Run Configuration shows a total of 714 plugins selected (which includes the 713 from the Target Platform, and mine). I can see that this list includes both org.eclipse.swt.win32.win32.x86_3.5.2.v34557f-RCP20100710-0200.jar and com.ibm.rcp.swtex.win32_6.2.2.20100729-1241.jar.

The problem:

  1. If I do not explicitly include the two aforementioned JAR files in my build path, the application fails to compile (trying to import org.eclipse.swt.widgets.Display and com.ibm.rcp.swt.swidgets.SToolItem).
  2. If I include the aforementioned JAR files in the build path, the application compiles, but won't run, due to a NoClassDefFound exception.

The questions:

  1. Why do I need to include these files in the first place? They are part of the workspace, and none of the other JAR files I'm referencing seem to need to be explicitly referenced.
  2. Why is this failing at run time? My understanding is that NoClassDefFound occurs because the class was available at compile time, but isn't at run time. But this is occurring on the same machine. (I'm trying to debug it locally, and I've even marked the JAR files for export!)

It seems to me that if the files are listed in the Runtime Configuration's loaded plugins tab, I wouldn't have to explicitly reference them. Am I incorrect regarding this? (Please be kind! I'm admittedly not an expert at this.)

Thanks in advance.

P.S. It's worth noting that if I include the files in the build path, I can see that they are properly referenced in both MANIFEST.MF and the .CLASSPATH file.

MANIFEST.MF CONTENTS

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Plugin
Bundle-SymbolicName: com.satuit.crm.plugin;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.satuit.crm.plugin.Activator
Bundle-Vendor: Satuit Technologies, Inc.
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.apache.axis,
 org.eclipse.ui;bundle-version="3.4.2",
 org.eclipse.core.runtime;bundle-version="3.4.0",
 org.eclipse.ui.views;bundle-version="3.3.1",
 com.ibm.rcp.jfaceex;bundle-version="6.2.2"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.satuit.crm.plugin,
 com.satuit.crm.plugin.document,
 com.satuit.crm.plugin.ui,
 com.satuit.crm.webservice.agent
Bundle-ClassPath: .,
 /NotesDev/Notes/framework/rcp/eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.5.2.v3557f-RCP20100710-0200.jar,
 /NotesDev/Notes/framework/rcp/eclipse/plugins/com.ibm.rcp.swtex.win32_6.2.2.20100729-1241.jar,
 /NotesDev/lib/activation-1.1.1.jar,
 /NotesDev/lib/mail.jar,
 /NotesDev/lib/commons-lang3-3.1.jar,
 /NotesDev/lib/SatuitCRM_XML_API2.jar

** .CLASSPATH CONTENTS **

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>  
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.5.2.v3557f-RCP20100710-0200.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Notes/framework/rcp/eclipse/plugins/com.ibm.rcp.swtex.win32_6.2.2.20100729-1241.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Workspace/lib/commons-lang3-3.1.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Workspace/lib/activation-1.1.1.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Workspace/lib/mail.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Workspace/lib/SatuitCRM_XML_API2.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/axispatch.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/axis.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/jaxrpc.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/saaj.jar"/>
    <classpathentry exported="true" kind="lib" path="C:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.apache.axis_1.4.0.20100729-1241/wsdl4j-1.5.1.jar"/>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

解决方案

Well, as it turns out, the OSGI manifest will accept absolute paths on the classpath. Surprise, surprise.

Whether or not it should is another story. And what that will do to the application once it's deployed is anyone's guess. But the runtime and compile time errors have disappeared, and so far don't appear to be resurfacing.

Once again, what we considered fact and actual fact turned out to be two very different things.

这篇关于奇怪的是“NoClassDefFound”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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