The activator for bundle is invalid
Asked Answered
R

14

17

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?

Rainbolt answered 20/8, 2009 at 10:42 Comment(2)
Can you post your Activator source?Seymore
It's a standard activator created using eclipse plugin templates.Rainbolt
B
17

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.

Baculiform answered 20/8, 2009 at 11:18 Comment(1)
I found the bug after long debugging session with breakpoints :) Somewhere in the code, I try to add an element to null array list! I focused on the bundle error and could not see it. Also, there was no exception for the array list. But, it's very interesting that, if I don't use a breakpoint, the debug session does not go into the class that contains the bug. The debug session terminates with the exception when I try create the object. So, we can say this is exactly ClassNotFoundException :)Rainbolt
S
3

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

Shanley answered 18/5, 2011 at 10:26 Comment(0)
D
2

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.

Dotson answered 3/6, 2011 at 14:23 Comment(0)
E
1

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.

Elasticity answered 21/4, 2011 at 3:9 Comment(0)
S
1

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

Sabayon answered 26/3, 2012 at 8:52 Comment(0)
K
1

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

Karleen answered 18/10, 2013 at 5:55 Comment(0)
G
1

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

Godroon answered 29/10, 2013 at 14:23 Comment(0)
T
1

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.
Ticktock answered 31/10, 2016 at 20:32 Comment(0)
R
0

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 ?

Rainbolt answered 28/8, 2009 at 6:44 Comment(1)
Just completed my answer in response to this comment.Baculiform
L
0

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
Luff answered 17/2, 2012 at 19:9 Comment(0)
I
0

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.

Importation answered 5/1, 2013 at 15:54 Comment(0)
E
0

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.

Eurythmic answered 22/7, 2013 at 15:25 Comment(0)
B
0

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)

Bayberry answered 21/11, 2014 at 1:13 Comment(0)
T
0

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.

Ticktock answered 2/5, 2016 at 9:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.