【问题标题】:Can't start OSGI bundle in Apache ServiceMix无法在 Apache ServiceMix 中启动 OSGI 包
【发布时间】:2018-04-17 07:12:33
【问题描述】:

我想创建 OSGI 包。我创建了一个简单的类:

public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
    System.out.println("::::START MAIL BUNDLE::::");
}

public void stop(BundleContext bundleContext) throws Exception {
    System.out.println("::::STOP MAIL BUNDLE::::");
}
}

我的pom.xml

<dependencies>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>6.0.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <executions>
                <execution>
                    <id>osgi-bundle</id>
                    <goals>
                        <goal>bundle</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <instructions>
                            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                            <Bundle-Version>${project.version}</Bundle-Version>
                            <Import-Package>
                                *;resolution:=optional
                            </Import-Package>
                        </instructions>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

我使用Service Mix。我在目标文件夹中添加org.osgi.core-6.0.0.jar 和我的 jar。我的捆绑包处于活动状态,但在 karaf 控制台中启动/停止捆绑包时看不到我的消息。我做错了什么?

【问题讨论】:

    标签: java osgi osgi-bundle apache-servicemix


    【解决方案1】:

    您必须在 maven-bundle-config 中设置 &lt;Bundle-Activator&gt;your.package.name.Activator&lt;/Bundle-Activator&gt;。 另请注意不要部署 org.osgi.core 或 org.osgi.componendium。核心包由 OSGi 框架部署,概要由各个规范实现。

    【讨论】:

      猜你喜欢
      • 2016-01-25
      • 2018-12-28
      • 2014-01-12
      • 2014-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-19
      • 2012-11-15
      相关资源
      最近更新 更多