The activator for bundle is invalid

2020-02-25 07:01发布

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?

14条回答
乱世女痞
2楼-- · 2020-02-25 07:10

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.
查看更多
家丑人穷心不美
3楼-- · 2020-02-25 07:12

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

查看更多
够拽才男人
4楼-- · 2020-02-25 07:17

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.

查看更多
我命由我不由天
5楼-- · 2020-02-25 07:19

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

查看更多
我只想做你的唯一
6楼-- · 2020-02-25 07:19

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 ?

查看更多
戒情不戒烟
7楼-- · 2020-02-25 07:21

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

查看更多
登录 后发表回答