java - OSGi 找不到激活器

标签 java osgi

list :

Manifest-Version: 1.0
Bundle-Name: Mahjong
Bundle-Activator: MahjongActivator
Bundle-SymbolicName: Mahjong
Bundle-Version: 1.0.0
Import-Package: org.osgi.framework

编译和震动:

$ javac -classpath equinox.jar src/start/*java
$ jar -cfm Mahjong.jar MahjongManifest.mf src/start/*class

激活器:

package start;

import org.osgi.framework.*;

public class MahjongActivator implements BundleActivator
{
    public void start(BundleContext context)
    {
        System.out.println("Hi!");
    }
    public void stop(BundleContext context)
    {
        System.out.println("Bye!");
    }
}

然后我在 OSGi 中加载 .jar,当我尝试 start() 它时,它会显示:

org.osgi.framework.BundleException: The activator MahjongActivator for bundle Mahjong is invalid
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:156)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:751)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:284)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:276)
...
Caused by: java.lang.ClassNotFoundException: MahjongActivator
...
some more ClassNotFounds...

为什么?

最佳答案

它应该是“Bundle-Activator: start.MahjongActivator”——您省略了包名称。

关于java - OSGi 找不到激活器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4952582/

相关文章:

java - 让球停下来

java - 使用jdbc连接到sql服务器

java - 测试 IllegalArgumentException 未按预期捕获

java - 公开远程接口(interface)或对象模型

java - 无法加载资源 : the server responded with a status of 404 ()

Java OSGi 集中式网络配置

java - 在 Eclipse 中安装插件要求我重新启动 Eclipse

osgi - WAB和WAR的区别

osgi - 从 Java 访问 Karaf cfg 文件中的属性?

java - 在控制台中使用 Scanner.nextLine() 或 Scanner.hasNext() 时是否可以不等待输入?