Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

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.

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.

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

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

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

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.

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 ?

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

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.

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.

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)

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top