捆绑包的激活器无效

发布于 2024-08-02 13:58:11 字数 195 浏览 6 评论 0原文

我正在尝试在 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 技术交流群。

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

发布评论

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

评论(14

¢蛋碎的人ぎ生 2024-08-09 13:58:11

检查您的 build.properties 部分

如果它没有正确指定最终二进制结果中应该包含的内容,它将无法工作。检查 .class 文件是否位于 MANIFEST.MF 指定的位置。


来自 EclipseZone,此错误消息的另一个原因:

如果您在日志中看到类似的消息

 The activator org.example.FooActivator for bundle org.example.foo is invalid 

,那么这通常意味着在调用该类之前,甚至在调用 start() 方法之前,就出现了 ClassNotFoundException 尝试加载该类。


penguru 添加:

当我尝试从激活器类的构造函数中的任何其他类创建新对象时,会发生错误。在激活器插件中创建对象不合法吗?

  • 如果该类来自另一个尚未“激活”的插件,那可能是您的问题。
  • 如果找不到该类,那么您的插件激活器也会失效。

基本建议:在 Activatorstart() 方法 而不是其构造函数。

Check your build.properties section

If 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:

If you see a message in the log like

 The activator org.example.FooActivator for bundle org.example.foo is invalid 

, then this usually means there has been a ClassNotFoundException trying to load the class in the first place, before it's even got to the start() method.


penguru adds:

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 plugin ?

  • If that class if from another plugin which has not yet been "activated", that could be your problem.
  • If that class is not found, that would also invalidate your plugin activator.

Basic advice: you may be better off with your initializations done in the start() method of Activator rather than its constructor.

血之狂魔 2024-08-09 13:58:11

从不同工作区导入插件时我也遇到了同样的问题。基本上,它是框架在加载类时查找的包类路径。当您导入到不同的工作区时,请确保更改类路径以指向适当的位置,即类文件所在的位置。

修改类路径后尝试清理并重新构建并重新运行。它应该有效..希望..

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..

黯然#的苍凉 2024-08-09 13:58:11

好吧,我讨厌在这里当队长,但我以前也犯过这个错误。当您忘记扩展 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.

一影成城 2024-08-09 13:58:11

如果您已将 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.

旧城烟雨 2024-08-09 13:58:11

我花了一些时间来解决这个问题。最后我注意到 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:

  • Go to "Install new software"
  • Click on "already installed"
  • Remove all instances of your package/plugin and restart

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

半寸时光 2024-08-09 13:58:11

就我而言,有一条消息“Activator ..invalid”,但在接下来的异常中,如果我没有更改某些内容,则捆绑包中存在 ClassNotFound 异常。Guu

(也发布了解决方案)是我的英雄,在增加

Bundle-ManifestVersion: 2

一切

Bundle-ManifestVersion: 3

正常:)

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

Bundle-ManifestVersion: 2

to

Bundle-ManifestVersion: 3

everything works :)

我三岁 2024-08-09 13:58:11

我也遇到了同样的例外。根本问题是 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

心欲静而疯不止 2024-08-09 13:58:11

如果您在另一个包中的包之后命名一个包,也可能会发生这种情况。

因此:

  • 如果您有包含包 org.my.package.name.function 的 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:

  • if you have Bundle A which contains package org.my.package.name.function,
  • and you create bundle B with name org.my.package.name.function,
    • => then the system may look for the activator there, and not find any.
自由如风 2024-08-09 13:58:11

我找到了错误的原因。当我尝试从激活器类的构造函数中的任何其他类创建新对象时,会发生错误。在插件的激活器中创建对象不合法吗?

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 ?

勿挽旧人 2024-08-09 13:58:11

就我而言,此异常是因为 Eclipse 自定义类加载器无法及时解析和加载其他插件中的所有依赖类。我不是 Eclipse 超级大师,所以也许这是我的错。

不过,它是通过禁用插件的延迟加载来修复的。在 GUI 中,MANIFEST.MF 编辑器的概述选项卡上,取消选中加载其类之一时激活此插件。或者直接在MANIFEST.MF删除行

Bundle-ActivationPolicy: lazy

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 in MANIFEST.MF delete line

Bundle-ActivationPolicy: lazy
你另情深 2024-08-09 13:58:11

另一个明显的队长:如果您更改源文件的路径(例如 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.

尾戒 2024-08-09 13:58:11

我遇到了同样的错误,在我的例子中,我创建了自己的带有参数的构造函数。但我没有提供默认构造函数。因此,在删除我的构造函数并在 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.

泪是无色的血 2024-08-09 13:58:11

我也遇到了同样的错误。捆绑包 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)

九八野马 2024-08-09 13:58:11

我在“捆绑”普通 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文