未找到OSGi捆绑包的Activator类

时间:2015-05-08 16:29:41

标签: java eclipse osgi equinox osgi-bundle

我有一个OSGi包,它有一个激活类。我在我的webapp中嵌入了Equinox,并在其中安装了我的软件包。安装顺利,但是当我尝试启动捆绑包时,会出现以下错误:

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

我可以看到找不到我的激活类。我搜索了一个解决方案并在SO中找到了一些有趣的东西,但是没有一个能帮助我。

这是我的清单:

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

我可以加入我的Activator,但我认为它不会有帮助,因为它甚至找不到,所以我不认为它的来源与错误有任何关系。

我在JAR中的bundle的库结构如下:

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

我使用Eclipse PDE创建我的包:导出... /可部署的插件和片段

我的build.properties包括META-INF和目标库,JAR和plugin.xml,因为它可以在捆绑结构中看到。

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

我将重申bkail的建议作为答案。当你的包被包含在" target / classes"文件夹,它们基本上在该包中: target.classes.com.rr.fr.base.barcode。*

您的包结构(com)的根应该是META-INF和/或OSGI-INF等的对等。

答案 1 :(得分:0)

来自: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>