几天前,我们决定在Eclipse RCP应用程序中开始使用Guava。我从http://central.maven.org/maven2/com/google/guava/guava/14.0.1/下载了guava-14.0.1.jar。
启动eclipse.exe后,应用程序崩溃了。 .metadata / .log文件包含以下错误:
!ENTRY org.eclipse.osgi 4 0 2013-08-12 15:56:32.033
!MESSAGE Application error
!STACK 1
java.lang.NoClassDefFoundError: com/google/common/base/Optional
at com.treeage.treeagepro.license.LicenseLevel.<clinit>(Unknown Source)
at com.treeage.treeagepro.license.LicenseInfo.<init>(Unknown Source)
at com.treeage.treeagepro.license.LicenseManager.<init>(Unknown Source)
at com.treeage.treeagepro.license.LicenseManager.getManager(Unknown Source)
at com.treeage.treeagepro.app.ApplicationWorkbenchAdvisor.initialize(Unknown Source)
at org.eclipse.ui.application.WorkbenchAdvisor.internalBasicInitialize(WorkbenchAdvisor.java:188)
at org.eclipse.ui.internal.Workbench$28.runWithException(Workbench.java:1541)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.treeage.treeagepro.app.Application.start(Unknown Source)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Optional
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 31 more
如果应用程序以管理员身份运行,则没有错误。
应用程序是64位,因此这不是UAC虚拟化问题。但看起来这个问题在某种程度上与权限有关。
guava-14.0.1.jar似乎是一个有效的OSGi包:https://code.google.com/p/guava-libraries/issues/detail?id=688(至少我在MANIFEST.MF中找到了所有必需的头文件)
有什么建议吗?
答案 0 :(得分:1)
我通过清除C:\Users\<user_name>\.eclipse
文件夹修复了我的问题。看起来这个问题与OSGi(Equinox)临时目录有某种联系。
答案 1 :(得分:0)
仔细检查您是否已将捆绑包包含在RCP产品配置中使用的功能中。 仔细检查您是否使用了正确的符号名称,以及是否需要正确的版本。 我遇到了像你这样的问题,因为番石榴罐在构建时没有被正确复制到目标平台。
在我的情况下,我必须在feature.xml中添加以下内容,以确保复制版本0.14.1,因为Eclipse Xtext和其他组件使用较旧的版本:
<requires>
<import plugin="com.google.guava" version="0.14.1"/>
....
</requires>
<plugin
id="com.google.guava"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
答案 2 :(得分:0)
根据您的上一条评论,我认为这不是Java或OSGi相关,但可能只是文件系统权限问题。
您可能想要: