1

I have an OSGi bundle, which has an activator class. I embedded Equinox in my webapp, and installed my bundle in it. The installation goes well, but when I try to start the bundle, the following error comes:

org.osgi.framework.BundleException: The activator com.rr.fr.base.barcode.activator.Activator for bundle fr-base-barcode is invalid
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:171)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:291)
    at com.rr.fr.base.osgi.BundleStarter.launch(BundleStarter.java:43)
    at com.rr.fr.base.osgi.OsgiInitServletContextListener.contextInitialized(OsgiInitServletContextListener.java:41)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.rr.fr.base.barcode.activator.Activator
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:345)
    at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:164)
    ... 21 more

I can see that my activator class was not found. I searched for a solution and find some interesting thing here in SO, but none of them helped me.

Here is my manifest:

Manifest-Version: 1.0
Bnd-LastModified: 1431100911346
Build-Jdk: 1.6.0_45
Bundle-Activator: com.rr.fr.base.barcode.activator.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: fr-base-barcode;singleton:=true
Bundle-Version: 0.1.2.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Import-Package: com.rr.fr.base.barcode.qrcode.interfaces,com.rr.fr.base.
 exception,com.rr.fr.base.messages,com.rr.fr.base.system,com.rr.fr.base.
 types,com.rr.fr.interfaces,com.rr.fr.interfaces.eb.rms,com.rr.fr.ui.htt
 p,hu.posta.rsaqrgen,javax.servlet,javax.servlet.http,org.apache.avalon.
 framework.configuration,org.apache.commons.logging,or
 g.krysalis.barcode4j,org.krysalis.barcode4j.output,org.krysalis.barcode
 4j.output.bitmap,org.krysalis.barcode4j.output.eps,org.osgi.framework,org.osgi.service.http,org.osgi.util.
 tracker

I can include my Activator, but I don't think it would help since it isn't even found so I don't think its source has anything to do with the error.

My bundle's library structure inside the JAR is the following:

META-INF
    /MANIFEST.MF
target
    /classes
        /com
            /rr
                /fr
                    /base
                        /barcode
                            ...
fr-base-barcode.jar
plugin.xml

I create my bundle with Eclipse PDE: Export.../Deployable Plug-ins and fragments

My build.properties includes the META-INF and target libraries, a JAR and plugin.xml as it can be seen in the bundle structure.

Any help would be appreciated.

5
  • 2
    That "target/classes" folder looks wrong. I assume that's being added by the Maven plugin. Perhaps try manually rebuilding the JAR without that to see if it's the problem?
    – Brett Kail
    May 8, 2015 at 16:45
  • 2
    The nested fr-base-barcode.jar isn't going to work without a Bundle-ClassPath either. I guess you could try Bundle-Classpath: target/classes fr-base-barcode.jar, but I would still try to figure out how to get rid of that target/classes folder since it's rather atypical.
    – Brett Kail
    May 8, 2015 at 16:46
  • Thanks for your answer. Could you please specify what is actually wrong with the target/classes folder? Of course under the /barcode folder there are more folders with the class files inside, for example the activator/Activator.class So the activator class is 'com.rr.fr.base.barcode.activator.Activator.class' Shouldn't the class files be in such a structure?
    – Tamas G.
    May 8, 2015 at 17:06
  • Oh I guess they shouldn't be in target/classes.
    – Tamas G.
    May 8, 2015 at 17:12
  • And that way it works! Thank you very much! If you write an answer, I can accept it.
    – Tamas G.
    May 8, 2015 at 17:17

2 Answers 2

2

I'm going to restate bkail's suggestion as the answer. When your packages are included in the "target/classes" folder, they are essentially in that package: target.classes.com.rr.fr.base.barcode.*

The root of your package structure (com) should be a peer of META-INF and/or OSGI-INF, etc.

0

From : https://netbeans.org/kb/docs/javaee/maven-osgiservice-cdi.html#Exercise_3

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    <manifestEntries>
                        <Bundle-ClassPath>WEB-INF/classes/</Bundle-ClassPath>
                    </manifestEntries>
                </archive>
            </configuration>                
        </plugin>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.