The activator for bundle is invalid

后端 未结 14 2133
-上瘾入骨i
-上瘾入骨i 2020-12-30 04:31

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 a

相关标签:
14条回答
  • 2020-12-30 04:55

    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

    0 讨论(0)
  • 2020-12-30 04:59

    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 ?

    0 讨论(0)
  • 2020-12-30 05:02

    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.

    0 讨论(0)
  • 2020-12-30 05:02

    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
    
    0 讨论(0)
  • 2020-12-30 05:06

    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.

    0 讨论(0)
  • 2020-12-30 05:10

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

    0 讨论(0)
提交回复
热议问题