Eclipse RCP 应用程序中的 NoClassDefFoundError

发布于 2024-12-16 19:37:55 字数 7359 浏览 0 评论 0原文

在我们的应用程序中,我们有时(大约十分之一)会得到一个 NoClassDefFoundError 尝试实例化类时。当没有我们的应用程序打开项目时就会发生这种情况。

完整的堆栈跟踪如下所示:

!ENTRY org.eclipse.jface 4 2 2011-11-18 12:45:33.941
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
!STACK 0
java.lang.NoClassDefFoundError: com.mycompany.products.myapp.gui.model.provider.EMyAppObjectItemProvider
    at com.mycompany.products.myapp.gui.model.provider.MyappguimodelItemProviderAdapterFactory.createMyAppGuiPortAdapter(MyappguimodelItemProviderAdapterFactory.java:159)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelAdapterFactory$1.caseMyAppGuiPort(MyappguimodelAdapterFactory.java:185)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelAdapterFactory$1.caseMyAppGuiPort(MyappguimodelAdapterFactory.java:1)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelSwitch.doSwitch(MyappguimodelSwitch.java:226)
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:59)
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:75)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelAdapterFactory.createAdapter(MyappguimodelAdapterFactory.java:462)
    at org.eclipse.emf.common.notify.impl.AdapterFactoryImpl.createAdapter(AdapterFactoryImpl.java:133)
    at org.eclipse.emf.common.notify.impl.AdapterFactoryImpl.adaptNew(AdapterFactoryImpl.java:107)
    at org.eclipse.emf.common.notify.impl.AdapterFactoryImpl.adapt(AdapterFactoryImpl.java:93)
    at com.mycompany.products.myapp.gui.model.provider.MyappguimodelItemProviderAdapterFactory.adapt(MyappguimodelItemProviderAdapterFactory.java:1127)
    at org.eclipse.emf.edit.provider.ComposedAdapterFactory.adapt(ComposedAdapterFactory.java:300)
    at org.eclipse.emf.edit.provider.ComposedAdapterFactory.adapt(ComposedAdapterFactory.java:277)
    at org.eclipse.emf.edit.provider.ComposedAdapterFactory.adapt(ComposedAdapterFactory.java:264)
    at org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider.getColumnText(AdapterFactoryLabelProvider.java:496)
    at org.eclipse.jface.viewers.TableColumnViewerLabelProvider.update(TableColumnViewerLabelProvider.java:70)
    at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:152)
    at org.eclipse.jface.viewers.AbstractTableViewer.doUpdateItem(AbstractTableViewer.java:399)
    at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:485)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
    at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2167)
    at org.eclipse.jface.viewers.AbstractTableViewer.createItem(AbstractTableViewer.java:277)
    at org.eclipse.jface.viewers.AbstractTableViewer.internalRefreshAll(AbstractTableViewer.java:757)
    at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:649)
    at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:636)
    at org.eclipse.jface.viewers.AbstractTableViewer$2.run(AbstractTableViewer.java:592)
    at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1443)
    at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1404)
    at org.eclipse.jface.viewers.AbstractTableViewer.inputChanged(AbstractTableViewer.java:590)
    at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:280)
    at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1690)
    at com.mycompany.products.myapp.gui.views.port.composites.Ipv4PortComposite.projectOpenedOrClosed(Ipv4PortComposite.java:732)
    at com.mycompany.products.myapp.gui.project.MyAppResourceController.tellOpenCloseListeners(MyAppResourceController.java:186)
    at com.mycompany.products.myapp.gui.actions.project.MyAppGuiResourceController.openProject(MyAppGuiResourceController.java:266)
    at com.mycompany.products.myapp.gui.project.MyAppResourceController.open(MyAppResourceController.java:592)
    at com.mycompany.products.myapp.gui.project.MyAppResourceController.openWithoutUpdating(MyAppResourceController.java:612)
    at com.mycompany.products.myapp.gui.actions.file.MyAppRecentProjectAction.run(MyAppRecentProjectAction.java:55)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at com.mycompany.products.myapp.gui.MyAppApplication.start(MyAppApplication.java:175)
    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:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.M

这些相关问题没有回答我的问题:

当在运行时类路径中找不到该类时,会发生此异常。因此,我认为如果我可以在实际尝试实例化之前打印运行时搜索路径,将会很有用。这样我就可以检查失败的 1/10 次是否有任何差异。但是,我还没有找到如何获取运行时搜索路径列表。关于如何获得它们有任何提示吗?

谁能帮我解决这个问题吗?

In our application we sometimes (about 1 out of 10 times) get a NoClassDefFoundError when trying to instantiate a class. It happens when a project is opened from without our application.

The full stack trace looks like this:

!ENTRY org.eclipse.jface 4 2 2011-11-18 12:45:33.941
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
!STACK 0
java.lang.NoClassDefFoundError: com.mycompany.products.myapp.gui.model.provider.EMyAppObjectItemProvider
    at com.mycompany.products.myapp.gui.model.provider.MyappguimodelItemProviderAdapterFactory.createMyAppGuiPortAdapter(MyappguimodelItemProviderAdapterFactory.java:159)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelAdapterFactory$1.caseMyAppGuiPort(MyappguimodelAdapterFactory.java:185)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelAdapterFactory$1.caseMyAppGuiPort(MyappguimodelAdapterFactory.java:1)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelSwitch.doSwitch(MyappguimodelSwitch.java:226)
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:59)
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:75)
    at com.mycompany.products.myapp.gui.model.util.MyappguimodelAdapterFactory.createAdapter(MyappguimodelAdapterFactory.java:462)
    at org.eclipse.emf.common.notify.impl.AdapterFactoryImpl.createAdapter(AdapterFactoryImpl.java:133)
    at org.eclipse.emf.common.notify.impl.AdapterFactoryImpl.adaptNew(AdapterFactoryImpl.java:107)
    at org.eclipse.emf.common.notify.impl.AdapterFactoryImpl.adapt(AdapterFactoryImpl.java:93)
    at com.mycompany.products.myapp.gui.model.provider.MyappguimodelItemProviderAdapterFactory.adapt(MyappguimodelItemProviderAdapterFactory.java:1127)
    at org.eclipse.emf.edit.provider.ComposedAdapterFactory.adapt(ComposedAdapterFactory.java:300)
    at org.eclipse.emf.edit.provider.ComposedAdapterFactory.adapt(ComposedAdapterFactory.java:277)
    at org.eclipse.emf.edit.provider.ComposedAdapterFactory.adapt(ComposedAdapterFactory.java:264)
    at org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider.getColumnText(AdapterFactoryLabelProvider.java:496)
    at org.eclipse.jface.viewers.TableColumnViewerLabelProvider.update(TableColumnViewerLabelProvider.java:70)
    at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:152)
    at org.eclipse.jface.viewers.AbstractTableViewer.doUpdateItem(AbstractTableViewer.java:399)
    at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:485)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
    at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2167)
    at org.eclipse.jface.viewers.AbstractTableViewer.createItem(AbstractTableViewer.java:277)
    at org.eclipse.jface.viewers.AbstractTableViewer.internalRefreshAll(AbstractTableViewer.java:757)
    at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:649)
    at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:636)
    at org.eclipse.jface.viewers.AbstractTableViewer$2.run(AbstractTableViewer.java:592)
    at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1443)
    at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1404)
    at org.eclipse.jface.viewers.AbstractTableViewer.inputChanged(AbstractTableViewer.java:590)
    at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:280)
    at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1690)
    at com.mycompany.products.myapp.gui.views.port.composites.Ipv4PortComposite.projectOpenedOrClosed(Ipv4PortComposite.java:732)
    at com.mycompany.products.myapp.gui.project.MyAppResourceController.tellOpenCloseListeners(MyAppResourceController.java:186)
    at com.mycompany.products.myapp.gui.actions.project.MyAppGuiResourceController.openProject(MyAppGuiResourceController.java:266)
    at com.mycompany.products.myapp.gui.project.MyAppResourceController.open(MyAppResourceController.java:592)
    at com.mycompany.products.myapp.gui.project.MyAppResourceController.openWithoutUpdating(MyAppResourceController.java:612)
    at com.mycompany.products.myapp.gui.actions.file.MyAppRecentProjectAction.run(MyAppRecentProjectAction.java:55)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at com.mycompany.products.myapp.gui.MyAppApplication.start(MyAppApplication.java:175)
    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:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.M

These related questions didn't answer my problem:

From what I've read this exception occurs when the class is not found in the runtime class-path. So I think it would be useful if I could print the runtime search paths before the actual attempt at instantiation. This way I can check if there is any difference in the 1/10 times it fails. However, I haven't found yet how to get the list of runtime search paths. Any hints on how to get them?

Can anyone help me fix this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧城空念 2024-12-23 19:37:55

对于类加载问题,Java 提供了一些工具。看看你真的在 Slideshare 上获得了类加载器吗?我曾经在集成到我的 RCP 产品中的 Eclipse 帮助系统中遇到过类似的问题。当在 IDE 中启动时,一切工作正常,但是当启动导出的产品时,帮助系统就不会出现。

For classloading issues Java offers some tools. Look Do you really get class loaders on Slideshare. I once had a similar problem with the help system of Eclipse which I integrated in my RCP product. When started within the IDE everything worked fine but when starting the exported product the help system just doesn't come up.

动次打次papapa 2024-12-23 19:37:55

启动应用程序时您是否收到此消息?这听起来好像有些捆绑包尚未初始化。 OSGi 将根据依赖关系启动模块,但是当您没有设置正确的依赖关系时,会出现一个随机元素。我建议看看那个。如果您需要更多信息,可以使用 OSGi 控制台检查您的环境:

http://www.ibm.com/developerworks/library/os-ecl-osgiconsole/index.html

希望这会有所帮助。

Do you get this when starting the application? This sounds like some bundles haven't been initialized at that point. OSGi will start modules based on the dependencies, but there's a random element when you don't have the proper dependencies set in place. I would suggest looking at that. If you want more info, you can use the OSGi console to examine your environment:

http://www.ibm.com/developerworks/library/os-ecl-osgiconsole/index.html

Hope this helps.

十级心震 2024-12-23 19:37:55

尝试在启用 OSGi 控制台 (-console) 的情况下在调试器中运行应用程序。为 NoClassDefFoundError 添加类断点,或者在有问题的代码行 (MyappguimodelItemProviderAdapterFactory.java:159) 上添加一个类断点。

并且,当断点被击中时:

  • 使用 MyappguimodelItemProviderAdapterFactory 查找包的包 ID - 例如使用 ss OSGi 命令
  • 使用 查找包的完整状态Bundle OSGi 命令
  • 检查有问题的包 - com.mycompany.products.myapp.gui.model.provider - 在“导入的包”部分

我不知道可能出了什么问题,但您应该检查是否

  • 已设置正确的包接线 - 可能使用 packages com.mycompany.products.myapp.gui.model.provider OSGi 命令查找所有提供程序
  • EMyAppObjectItemProvider 的捆绑包实际上包含该类 - 您可以使用 status OSGi 命令找到 OSGi 使用的 jar (不要以为你知道:-))

Try to run your application in the debugger with the OSGi console enabled (-console). Add a Class breakpoint for NoClassDefFoundError or alternatively on the offending line of code (MyappguimodelItemProviderAdapterFactory.java:159).

And, when the breakpoint is hit:

  • find the bundle ID of the bundle with MyappguimodelItemProviderAdapterFactory - e.g. with the ss OSGi command
  • find the complete status of the bundle with the bundle <id> OSGi command
  • check whether the package in question - com.mycompany.products.myapp.gui.model.provider - is wired correctly in the "Imported Packages" section

I don't know what can be wrong, but you should check that

  • the correct package wiring has been set up - possibly using packages com.mycompany.products.myapp.gui.model.provider OSGi command to find all the providers
  • the bundle with EMyAppObjectItemProvider actually includes the class - you can find the jar used by OSGi with the status OSGi command (don't assume you know :-))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文