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