2011-11-18 280 views
0

在我們的應用程序中,我們有時(大約10次中有1次)嘗試實例化類時得到NoClassDefFoundError。當沒有我們的應用程序打開項目時會發生這種情況。Eclipse RCP應用程序中的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 

這些相關問題沒有回答我的問題:

從我」當這個類不是基金會的時候就會發生這種異常d在運行時類路徑中。所以我認爲如果我能夠在實際嘗試實例化之前打印運行時搜索路徑會很有用。這樣我可以檢查它在1/10次失敗中是否有任何差異。但是,我還沒有找到如何獲得運行時搜索路徑列表。有關如何獲得它們的任何提示?

任何人都可以幫助我解決這個問題嗎?

回答

1

你在啓動應用程序時得到了這個嗎?這聽起來像一些捆綁包在那個時候還沒有初始化。 OSGi將根據依賴關係啓動模塊,但如果沒有適當的依賴關係,則會有一個隨機元素。我會建議看看。如果您想了解更多信息,您可以使用OSGi控制檯來檢查您的環境:

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

希望這有助於。

+0

它發生在程序啓動後不久,通常在第一次用戶操作。我也認爲它與依賴管理有關,但還沒有發現任何錯誤。我會看看你的鏈接。 – StackedCrooked

+0

EMyAppObjectItemProvider和MyAppApplication是否在同一個包中?它是否總是發生在同一班?在同一捆綁中的類? –

+0

EMyAppObjectItemProvider和MyAppApplication位於不同的包中。是的,它總是在相同的代碼行中發生。 – StackedCrooked

1

嘗試在啓用OSGi控制檯的調試器中運行您的應用程序(-console)。爲NoClassDefFoundError或代碼行(MyappguimodelItemProviderAdapterFactory.java:159)添加類斷點。

而且,當斷點命中:

  • 找到MyappguimodelItemProviderAdapterFactory該包的包ID - 例如與ss OSGi的命令
  • 找到包的完整狀態與bundle <id> OSGi的命令
  • 檢查是否包有問題 - com.mycompany.products.myapp.gui.model.provider - 被部分

我不正確連接,在「導入包」 「知道什麼可以是錯誤的,但你應該檢查

  • 正確的包線已設置 - 可能使用packages com.mycompany.products.myapp.gui.model.provider OSGi的命令查找所有的供應商
  • EMyAppObjectItemProvider捆實際上包括類 - 你可以找到使用的OSGi與OSGi的status命令的jar(不要以爲你知道:-))
3

對於類加載器發出的Java提供了一些工具。在Slideshare上看Do you really get class loaders。我曾經與Eclipse的幫助系統有過類似的問題,我將其集成到我的RCP產品中。在IDE內啓動時,一切正常,但啓動導出產品時,幫助系統無法啓動。

相關問題