Tamas G.
Tamas G.

Reputation: 737

OSGi bundle's Activator class not found

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.

Upvotes: 1

Views: 4851

Answers (2)

jorelia
jorelia

Reputation: 1

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>

Upvotes: 0

ebullient
ebullient

Reputation: 1280

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.

Upvotes: 2

Related Questions