捆绑包的激活器无效
我正在尝试在 Eclipse 中创建一个简单的插件。当我运行该应用程序时,我在日志文件中看到以下错误:
org.osgi.framework.BundleException:捆绑包的激活器 捆绑包 org.xy 的 org.xyActivator 无效。
您对这个错误有什么想法吗?
I'm trying to create a simple plugin in eclipse. When I run the application, I see this error in log file:
org.osgi.framework.BundleException : The activator for bundle
org.x.y.Activator for bundle org.x.y is invalid.
Do you have any idea about this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
检查您的
build.properties
部分如果它没有正确指定最终二进制结果中应该包含的内容,它将无法工作。检查 .class 文件是否位于 MANIFEST.MF 指定的位置。
来自 EclipseZone,此错误消息的另一个原因:
penguru 添加:
基本建议:在
Activator
的start()
方法 而不是其构造函数。Check your
build.properties
sectionIf it doesn't properly specify what's supposed to be in the final binary result, it will not work. Check the .class files are where the MANIFEST.MF says they will be.
from EclipseZone, another reason for this error message:
penguru adds:
Basic advice: you may be better off with your initializations done in the
start()
method ofActivator
rather than its constructor.从不同工作区导入插件时我也遇到了同样的问题。基本上,它是框架在加载类时查找的包类路径。当您导入到不同的工作区时,请确保更改类路径以指向适当的位置,即类文件所在的位置。
修改类路径后尝试清理并重新构建并重新运行。它应该有效..希望..
I also faced same issue while importing plugins from different workspace. Basically, it is the bundle classpath where the framework looks for while loading the classes. When you import to a different workspace, make sure you change the class path to point to appropriate location i.e. where the class file are present.
After modifying the classpath try to clean and re-build and re-run. It should work..hopefully..
好吧,我讨厌在这里当队长,但我以前也犯过这个错误。当您忘记扩展 BundleActivator 时,也可能会发生这种情况。
OK, I hate to be captain obvious here, but I've made this mistake before. This can also happen when you forget to extend BundleActivator.
如果您已将 Eclipse 工作区移动到新路径,那么您应该在插件构建之前使用项目->clean,否则您会遇到此问题。
If you have move the eclipse workspace to a new path, then you should use the project->clean before your plugin build, Or you would meet this problem.
我花了一些时间来解决这个问题。最后我注意到 ClassNotFoundExceptions 与我的代码不符,它们来自错误的(旧的)包。我检查了是否有其他插件扰乱了我的调试/导出,确实有,我自己的插件!
因此,如果您遇到此问题并且 CNFE 与您的代码不符,可以尝试一个简单的修复:
可能是由于此原因造成的因为我更改了插件ID,使得Eclipse将其视为新插件。
如果您感到沮丧和卡住,可以看看另一个好网站: http://www .eclipsezone.com/eclipse/forums/t99010.html
I spent some time with this problem. Finally I noticed that the ClassNotFoundExceptions were not in line with my code, they were coming from wrong (old) packages. I checked if there was some other plugin which was messing with my debugs/exports and indeed there was, my own plugin!
So a simple fix to try if you're facing this and the CNFE's are not in line with your code:
Likely this was caused because I changed the plugin ID, making Eclipse treat it as a new plugin.
Another good site to take a look if you're getting frustrated and stuck: http://www.eclipsezone.com/eclipse/forums/t99010.html
就我而言,有一条消息“Activator ..invalid”,但在接下来的异常中,如果我没有更改某些内容,则捆绑包中存在 ClassNotFound 异常。Guu
(也发布了解决方案)是我的英雄,在增加
一切
正常:)
In my case there was this Message "Activator ..invalid" but in the next exceptions there were ClassNotFound Exceptions in a Bundle were i didnt change something..
Guu(Posted a solution too) is my hero, After increasing
to
everything works :)
我也遇到了同样的例外。根本问题是 ClassCastException。我的捆绑包需要 org.osgi.core 4.3,而 equinox 启动器使用 4.2。
问候
罗兰
I got the same exception. The underlying problem was a ClassCastException. My bundle requires org.osgi.core 4.3 whereas the equinox launcher uses 4.2.
Regards
Roland
如果您在另一个包中的包之后命名一个包,也可能会发生这种情况。
因此:
Bundle A
,bundle B
>org.my.package.name.function,This can also happen if you name a bundle after a package in another bundle.
So:
Bundle A
which contains packageorg.my.package.name.function
,bundle B
with nameorg.my.package.name.function
,我找到了错误的原因。当我尝试从激活器类的构造函数中的任何其他类创建新对象时,会发生错误。在插件的激活器中创建对象不合法吗?
I found the reason of the error. The error occurs when i try create a new object from any other class in the constructor of activator class. Isn't it legal to create an object in activator of plugin ?
就我而言,此异常是因为 Eclipse 自定义类加载器无法及时解析和加载其他插件中的所有依赖类。我不是 Eclipse 超级大师,所以也许这是我的错。
不过,它是通过禁用插件的延迟加载来修复的。在 GUI 中,
MANIFEST.MF
编辑器的概述选项卡上,取消选中加载其类之一时激活此插件。或者直接在MANIFEST.MF
删除行In my case this exception was because of inability of Eclipse custom class loader to resolve and load all depending classes from other plugins in-time. I am not Eclipse super-guru so maybe it was my fault.
However it was fixed by disabling lazy loading of plugin. In GUI on Overview tab of
MANIFEST.MF
editor uncheck Activate this plug-in when one of its classes is loaded. Or directly inMANIFEST.MF
delete line另一个明显的队长:如果您更改源文件的路径(例如 src/ 到 src/main/java ),但忘记更新 build.properties,编译总是会成功,但您的插件将永远无法工作。
Another captain obvious: If you change the paths of your source files (e.g. src/ to src/main/java), but forget to update build.properties, the compilation will always succeed, but your plugin will never work.
我遇到了同样的错误,在我的例子中,我创建了自己的带有参数的构造函数。但我没有提供默认构造函数。因此,在删除我的构造函数并在 start() 方法中初始化所有内容之后,它的工作方式就像魅力一样。
I had the same error, in my case I created my own constructor with parameters. But I didn't provide a default constructor. So after removing my constructor and initialized all within the start() method, it worked like charme.
我也遇到了同样的错误。捆绑包 XX 的激活器 XX 无效,并且 ClassNotFoundException。
我检查了plugins\目录,没有找到所需的类。
--
因为没有包含所需类的jar文件,所以只有相应的目录。
例如,没有com.hh.jar,只有com.hh目录。
所以,创建 com.hh.jar 一定有问题。
如果 com.hh.jar 引用了其他插件,那么也检查它们。
我通过编辑 MANIFEST.MF 解决了这个问题。
通过插件清单编辑器打开它,在运行时选项卡中,在“导出的包”中添加所需的包。
并在“类路径”中添加所需的库,然后“.” (当前目录,重要)
I also met the same error. The activator XX for bundle XX is invalid, and the ClassNotFoundException.
I checked plugins\ directory, and could not find the class needed.
--
Because there is no jar file containing the needed class, there is only the corresponding directory.
For example, there is no com.hh.jar, but only com.hh directory.
So, there must be something wrong about creating the com.hh.jar.
if com.hh.jar reference other plugins, then also check them.
I solved the problem by editing MANIFEST.MF.
Open it by Plug-in Manifest Editor, in runtime tab, add needed packages in "Exported Packages".
and in the "classpath", add needed libraries, and, "." (current directory, IMPORTANT)
我在“捆绑”普通 jar 文件时也遇到过这个问题。如果某些依赖项未解决,或者 jar 依赖于比您正在使用的 JAVA 版本更高的 JAVA 版本,则激活器将不会启动,从而出现上述异常。找出这是否是问题的快速方法是从包类路径(清单的运行时选项卡)中删除 jar,并检查激活器是否可以正确运行。
I have also run into this isue when 'bundle-izing' plain jar files. If some dependencies are not resolved, or jars depend on a higher JAVA version than the one you're using, the activator will not start, giving the above exception. The quick way to find out if this is the problem is to remove the jars from the bundle-classpath (runtime tab of the manifest) and check if the activator will run correctly.