2

When starting my OSGi application in eclipse, I get the following error:

org.osgi.framework.BundleException: The activator org.pathvisio.sbgn.SbgnPlugin for bundle org.pathvisio.sbgn is invalid
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:157)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:751)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
Caused by: java.lang.ClassNotFoundException: org.pathvisio.sbgn.SbgnPlugin
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:326)
    at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:231)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:150)
    ... 10 more

This seems to be the same problem as: The activator for bundle is invalid

However, no matter what I try, I keep getting that same error. Even if I change the name of the Activator class to something else, it's still giving me the exact same error using the old class name.

Apparently eclipse is caching something, but I have no idea what or why. I've tried restarting eclipse, and rebuilding all projects in my workspace, but nothing helps.

Here is my MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.pathvisio.sbgn
Bundle-SymbolicName: org.pathvisio.sbgn
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.pathvisio.sbgn.Activator
Bundle-ClassPath: lib/activation.jar,
 lib/google-collect-snapshot-20090211.jar,
 lib/jaxb-api.jar,
 lib/jaxb-impl.jar,
 lib/jaxb-xjc.jar,
 lib/jaxb1-impl.jar,
 lib/jsr173_1.0_api.jar,
 lib/org.sbgn.jar
Export-Package: org.pathvisio.sbgn
Require-Bundle: com.springsource.org.jdom;bundle-version="1.1.0",
 org.pathvisio.core;bundle-version="2.0.11",
 org.bridgedb;bundle-version="1.1.0",
 org.pathvisio.gui;bundle-version="2.0.11",
 org.pathvisio.desktop;bundle-version="2.0.11",
 org.bridgedb.bio;bundle-version="1.1.0"
Import-Package: org.osgi.framework;version="1.5.0"

As you can see I renamed the activator class, but it's still reporting the error using the class name that I specified previously.

Community
  • 1
  • 1
amarillion
  • 24,487
  • 15
  • 68
  • 80
  • Is it possible Eclipse requires the activator to be named after the plug-in/project? That would explain why its using the same name, even though you changed the activator. Have you tried using your bundle with another OSGi container (Virgo or Felix)? – TMN Oct 07 '11 at 14:17

4 Answers4

6

Add ., to Bundle-classpath and check again. It should work.

vp_java
  • 126
  • 2
  • 9
1

I experienced this problem after renaming the package of my Activator class. For anyone else that comes across it, eclipse had updated the references to the Activator in the MANIFEST.MF but not in the plugin.xml. In my case the plugin.xml was pointing to the old application

  <extension id="application" point="org.eclipse.core.runtime.applications">
  <application>
     <run class="old.app.Application">
     </run>
  </application>

So updated the plugin.xml and everything started up again.

kidloco
  • 829
  • 2
  • 8
  • 17
0

Eclipse caches really something! Go to your launch configuration and open the Settings tab. Choose the option Clear the configuration area before launching and try to run again your OSGi application!

Tim
  • 2,831
  • 1
  • 25
  • 37
0

Is there no chained exception? One reason is that your bundle does not import org.osgi.framework package. So the class load of your activator fails since your bundle class loader cannot load org.osgi.framework.BundleActivator.

BJ Hargrave
  • 9,324
  • 1
  • 19
  • 27
  • I edited my question to show the chained exception. It looks like the Activator class itself can't be found. I am definitely importing org.osgi.framework, so that's not the problem – amarillion Oct 07 '11 at 14:05
  • Where in the bundle is your activator class? I see that only nested jars are listed on the bundle class path. So no classes in the main bundle jar will be loaded! – BJ Hargrave Oct 07 '11 at 21:13