[英]Can't start OSGI bundle in Apache ServiceMix
I want create OSGI
bundle. 我想创建OSGI
包。 I createad a simple class: 我创建了一个简单的类:
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::::");
}
}
My pom.xml
: 我的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>
I using Service Mix
. 我使用Service Mix
。 I add org.osgi.core-6.0.0.jar
and my jar in target folder. 我在目标文件夹中添加了org.osgi.core-6.0.0.jar
和我的jar。 My bundle is active, but I don't see my message when start/stop bundle in karaf
console. 我的捆绑软件处于活动状态,但是在karaf
控制台中启动/停止捆绑软件时看不到我的消息。 What am I doing wrong? 我究竟做错了什么?
You have to set <Bundle-Activator>your.package.name.Activator</Bundle-Activator>
in the maven-bundle-config. 您必须在maven-bundle-config中设置<Bundle-Activator>your.package.name.Activator</Bundle-Activator>
。 Please also note to never deploy org.osgi.core or org.osgi.componendium. 另请注意,切勿部署org.osgi.core或org.osgi.componendium。 The core packages are deployed by the OSGi framework and compendium by the individual spec impls. 核心软件包由OSGi框架部署,而概要由各个规范隐含。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.