2

私は Eclipse RCP プラグイン開発に不慣れで、次の問題があります: プラグインで MessageConsole オブジェクトをインスタンス化しようとしています。MANIFEST.MF で org.eclipse.ui.console の適切な依存関係を作成し、プラグインをビルドしてから、同じ Eclipse アプリケーション内にプラグインをロードします (プラグインを zip としてエクスポートし、Eclipse をシャットダウンし、プラグインを解凍して、 Eclipse のプラグイン ディレクトリ、Eclipse を再起動します)。そのプラグインが読み込まれると、NoClassDefFoundError が発生します。MessageConsole をインスタンス化しようとする 1 つのソース コード行 (以下を参照) のコメントを外すと、プラグインは正常に動作します。詳細は以下の通りです。

マニフェスト.MF:

マニフェスト バージョン: 1.0
バンドル マニフェスト バージョン: 2
バンドル名: IntrospectorPlugin プラグイン
Bundle-SymbolicName: IntrospectorPlugin; シングルトン:=true
バンドル バージョン: 1.0.1
バンドル アクティベーター: introspectorplugin.Activator
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime、
 org.eclipse.ui.console
Bundle-ActivationPolicy: レイジー
バンドルが必要な実行環境: JavaSE-1.6

IntrospectorView.java:

org.eclipse.ui.console.ConsolePlugin をインポートします。
org.eclipse.ui.console.IConsole をインポートします。
org.eclipse.ui.console.IConsoleConstants をインポートします。
org.eclipse.ui.console.IConsoleView をインポートします。
org.eclipse.ui.console.MessageConsole をインポートします。
org.eclipse.ui.console.MessageConsoleStream をインポートします。
...
     MessageConsole myConsole = new MessageConsole("IntrospectorView プラグイン コンソール",
        imageDescriptorConsole);

例外:

java.lang.ClassNotFoundException: org.eclipse.ui.console.MessageConsole
    org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:483)で
    org.eclipse.osgi.framework.internal.core.BundleLoader.findClass (BundleLoader.java:399) で
    org.eclipse.osgi.framework.internal.core.BundleLoader.findClass (BundleLoader.java:387) で
    org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87) で
    java.lang.ClassLoader.loadClass で (不明なソース)
    java.lang.ClassLoader.loadClassInternal で (不明なソース)
    introspectorplugin.views.IntrospectorView.makeConsole (IntrospectorView.java:453) で
    introspectorplugin.views.IntrospectorView.createPartControl(IntrospectorView.java:436) で
    org.eclipse.ui.internal.ViewReference.createPartHelper (ViewReference.java:371) で
    org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:230) で
    org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594) で
    org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:306) で
    org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:531) で
    org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
    org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select (PresentablePartFolder.java:270) で
    org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select (LeftToRightTabOrder.java:65) で
    org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart (TabbedStackPresentation.java:473) で
    org.eclipse.ui.internal.PartStack.refreshPresentationSelection (PartStack.java:1256) で
    org.eclipse.ui.internal.PartStack.createControl (PartStack.java:668) で
    org.eclipse.ui.internal.PartStack.createControl (PartStack.java:576) で
    org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:568) で
    org.eclipse.ui.internal.PerspectiveHelper.activate (PerspectiveHelper.java:271) で
    org.eclipse.ui.internal.Perspective.onActivate (Perspective.java:968) で
    org.eclipse.ui.internal.WorkbenchPage.onActivate (WorkbenchPage.java:2593) で
    org.eclipse.ui.internal.WorkbenchWindow$25.run(WorkbenchWindow.java:2873)で
    org.eclipse.swt.custom.BusyIndi​​cator.showWhile (BusyIndi​​cator.java:70) で
    org.eclipse.ui.internal.WorkbenchWindow.setActivePage (WorkbenchWindow.java:2854) で
    org.eclipse.ui.internal.WorkbenchWindow$19.runWithException (WorkbenchWindow.java:2171) で
    org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) で
    org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) で
    org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:133) で
    org.eclipse.swt.widgets.Display.runAsyncMessages (Display.java:3800) で
    org.eclipse.swt.widgets.Display.readAndDispatch (Display.java:3425) で
    org.eclipse.ui.application.WorkbenchAdvisor.openWindows (WorkbenchAdvisor.java:803) で
    org.eclipse.ui.internal.Workbench$27.runWithException (Workbench.java:1363) で
    org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) で
    org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) で
    org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:133) で
    org.eclipse.swt.widgets.Display.runAsyncMessages (Display.java:3800) で
    org.eclipse.swt.widgets.Display.readAndDispatch (Display.java:3425) で
    org.eclipse.ui.internal.Workbench.runUI (Workbench.java:2295) で
    org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200) で
    org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495) で
    org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)で
    org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:490) で
    org.eclipse.ui.PlatformUI.createAndRunWorkbench (PlatformUI.java:149) で
    org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) で
    org.eclipse.equinox.internal.app.EclipseAppHandle.run (EclipseAppHandle.java:193) で
    org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication (EclipseAppLauncher.java:110) で
    org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start (EclipseAppLauncher.java:79) で
    org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:386) で
    org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:179) で
    sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブメソッド)
    sun.reflect.NativeMethodAccessorImpl.invoke (不明なソース) で
    sun.reflect.DelegatingMethodAccessorImpl.invoke (不明なソース) で
    java.lang.reflect.Method.invoke (不明なソース) で
    org.eclipse.equinox.launcher.Main.invokeFramework (Main.java:549) で
    org.eclipse.equinox.launcher.Main.basicRun (Main.java:504) で
    org.eclipse.equinox.launcher.Main.run (Main.java:1236) で

コンパイル時の依存関係が実行時の依存関係をターゲットにすることを確認することについて説明しているプラ​​グインの本を調べました-ビルドした同じEclipse実行可能ファイルでプラグインを実行すると、この問題は発生しませんか? さらに、プラグインの依存関係ツリーをたどり、必要なプラグインがすべて揃っていることを確認しました。

すべての助けに感謝します、ありがとう!

4

2 に答える 2

1

今日、新しいバージョンの Eclipse をインストールし、プラグインを plugins ディレクトリに追加したところ、すべてうまくいきました。明らかに、いくつかの構成の問題または癖に遭遇しました。以前のバージョンは Ganymede でしたが、現在は Galileo を実行しています。

于 2009-07-29T21:23:06.250 に答える
0

次のように、実装をコンソール ビューを含む他の例やプロジェクトと比較してみることができます。

どちらの場合も、依存関係 (plugin.xmlまたはMANIFEST.MF) をチェックして違いを確認し、プラグインに関連するクラスが含まれていない理由を説明してください。

于 2009-07-28T04:13:57.983 に答える