简体   繁体   English

eclipse4 RCP片段“无法从包中加载类”

[英]eclipse4 RCP Fragment “Unable to load class from bundle”

I currently try to migrate an Eclipse 3 RCP application to e4. 我目前正在尝试将Eclipse 3 RCP应用程序迁移到e4。 The project is based on a main plugin project and several fragment projects. 该项目基于一个主插件项目和几个片段项目。 I'm using Eclipse Mars for developing. 我正在使用Eclipse Mars进行开发。 The following description is based on a sample project I created for this. 以下描述基于我为此创建的示例项目。

The main application provides a simple menu with some handled menu items. 主应用程序提供了一个简单的菜单,其中包含一些已处理的菜单项。 The fragment should add some more menu items to this. 该片段应为此添加更多菜单项。 But I get an exception telling me, that the assigned handler class could not be loaded: 但是我得到一个异常告诉我,无法加载分配的处理程序类:

!ENTRY org.eclipse.e4.ui.workbench 4 0 2015-10-15 17:44:04.540
!MESSAGE Unable to load class 'de.fragment.Handler' from bundle '61'
!STACK 0
java.lang.ClassNotFoundException: Can not load a class from a fragment bundle: E4TestFragment_1.0.0.qualifier [61]

The structures of the both projects are more or less like follows. 这两个项目的结构大致如下。

Main application (eclipse PlugIn-Project): 主要应用程序(eclipse PlugIn-Project):

  • META-INF/MANIFEST.MF META-INF / MANIFEST.MF
  • Application.e4xmi Application.e4xmi
  • plugin.xml plugin.xml中

MANIFEST.MF content: MANIFEST.MF内容:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: E4Test3
Bundle-SymbolicName: E4Test3;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: javax.inject;bundle-version="1.0.0",
 org.eclipse.core.runtime;bundle-version="3.11.0",
 org.eclipse.swt;bundle-version="3.104.0",
 org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100",
 org.eclipse.jface;bundle-version="3.11.0",
 org.eclipse.e4.ui.services;bundle-version="1.2.0",
 org.eclipse.e4.ui.workbench;bundle-version="1.3.0",
 org.eclipse.e4.core.di;bundle-version="1.5.0",
 org.eclipse.e4.ui.di;bundle-version="1.1.0",
 org.eclipse.e4.core.contexts;bundle-version="1.4.0",
 org.eclipse.e4.ui.workbench.swt;bundle-version="0.13.0",
 org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.13.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .

Fragment (eclipse Fragment-Project): 片段(eclipse片段项目):

  • de/fragment/Handler.java DE /片段/ Handler.java
  • META-INF/MANIFEST.MF META-INF / MANIFEST.MF
  • fragment.e4xmi fragment.e4xmi
  • fragment.xml fragment.xml之

MANIFEST.MF content: MANIFEST.MF内容:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: E4TestFragment
Bundle-SymbolicName: E4TestFragment;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Fragment-Host:  E4Test3;bundle-version="1.0.0"
Export-Package: de.fragment
Bundle-ClassPath: .

The fragment.e4xmi itself is evaluated correctly. fragment.e4xmi本身已正确评估。 I checked this by removing the handler from the menu item which then just adds the icon to the gui. 我通过从菜单项中删除处理程序进行检查,然后将图标添加到gui中。

Honestly I have no idea what could cause this exception. 老实说,我不知道什么会导致此异常。 Does anyone of you have an idea and could help me? 你们中有人有想法可以帮助我吗?

Thanks in advance 提前致谢

I think you may be confusing two meanings of 'fragment' in Eclipse plugins. 我认为您可能会混淆Eclipse插件中“碎片”的两个含义。

You have a fragment.e4xmi which is the e4 meaning of 'fragment' - a fragment of the e4 model. 您有一个fragment.e4xmi ,它是“片段”的e4含义-e4模型的片段。

You have then put this in a 'fragment' plugin. 然后,将其放入“片段”插件中。 Fragment plugins are a different meaning of fragment and are not normal plugins. 片段插件是片段的不同含义,不是正常的插件。 In fact they are not separate plugins at all (instead they are just part of the host plugin). 实际上,它们根本不是单独的插件(相反,它们只是主机插件的一部分)。

Change your E4TestFragment to be a normal plugin. 将您的E4TestFragment更改为普通插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM