【问题标题】:Simple Hello World demonstrating OSGi with Akka Actors?使用 Akka Actor 演示 OSGi 的简单 Hello World?
【发布时间】:2013-11-06 19:18:54
【问题描述】:

我想创建一个非常简单的 (Hello Simple World) POC,演示将 OSGi (Felix) 与 Scala 和 Actors (Akka) 集成的能力。这是我目前所拥有的:

$ tree
.
├── bin
│   └── felix.jar
├── bundle
│   └── akka-osgi_2.10-2.2.1.jar
├── conf
    └── config.properties

$ cat conf/config.properties
org.osgi.framework.storage.clean: onFirstInit
org.osgi.framework.system.packages.extra: javafx
org.osgi.framework.bootdelegation: sun.misc
felix.auto.deploy.action=install,start
felix.log.level=1
org.osgi.service.http.port=8080
obr.repository.url=http://felix.apache.org/obr/releases.xml

$ java -jar bin/felix.jar
ERROR: Bundle com.typesafe.akka.osgi [1] Error starting file:/home/axiopisty/projects/test/bundle/akka-osgi_2.10-2.2.1.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle com.typesafe.akka.osgi [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=com.typesafe.config)(version>=0.4.1)(!(version>=1.1.0))))
org.osgi.framework.BundleException: Unresolved constraint in bundle com.typesafe.akka.osgi [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=com.typesafe.config)(version>=0.4.1)(!(version>=1.1.0)))
        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1291)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
        at java.lang.Thread.run(Thread.java:744)

我从这条错误消息中了解到,没有导出 osgi.wiring.package 的包。但我不知道我需要包含哪个包来导出该包。它会来自 Akka、Felix 还是其他地方?

从提供的 config.properties 中可以看出,我尝试按照 akka 文档中有关如何Configure the OSGi Framework 的说明进行操作,但我不知道我是否正在做他们所说的需要在正确的方法。

akka 文档说:

要在 OSGi 环境中使用 Akka, org.osgi.framework.bootdelegation 属性必须设置为 always 将 sun.misc 包委托给引导类加载器,而不是 通过正常的 OSGi 类空间解决它。

如何使用 Felix 作为 OSGi 容器并使用默认的 felix 启动器来做到这一点?

使用 OSGi(Felix 不是必需的,但首选)和 Akka Actors 的简单 hello world 示例是我正在寻找的理想选择。如果您知道 github(或其他地方)上的任何东西可以证明这一点,我也会接受它作为答案。

【问题讨论】:

  • osgi.wiring.package 不是包的名称。它是一般 Java 包的 命名空间。实际无法解析的包com.typesafe.config.
  • Akka 文档中关于使用 bootdelegation 的声明也是错误的,或者至少是被误导了。您应该通过设置org.osgi.framework.system.packages.extra 属性从系统包中导出sun.misc

标签: scala osgi akka apache-felix


【解决方案1】:

缺少要求 [1.0] osgi.wiring.package; (&(osgi.wiring.package=com.typesafe.config)

从您的错误消息的这一部分看来,您的包似乎找不到另一个提供 com.typesafe.config 的包,这是 akka 的依赖项。

您可以在创建捆绑包时使用bnd 工具的Conditional-Package Header/Instruction 来规避此问题。

【讨论】:

    【解决方案2】:

    Akka 源代码树中有一个示例 OSGi 应用程序。希望您可以将其用作起点。它使用 Karaf。

    https://github.com/akka/akka/tree/v2.2.3/akka-samples/akka-sample-osgi-dining-hakkers

    确保在稳定标记处签出代码,例如 v2.2.3,以便构建工具使用已发布的 Akka 稳定工件。

    【讨论】:

    • 我试过标签 v2.2.3 和 v2.3.6。他们都没有成功构建...... org.uncommons.maths.random FAILURE。无法解析罕见捆绑包的依赖关系。看起来问题是:对等体未通过身份验证。
    【解决方案3】:

    我已经开始把一个基于Karaf的OSGi容器放在一起并分享到了github上。现在它只是简单地将 ActorSystem 注册为服务,并使用该系统在其中包含一个包含 Actor 的演示包。它被配置为登录到正常的 karaf.log。

    代码示例可以在github 上找到。

    最好的问候 安德烈亚斯

    【讨论】:

    • 提供的 github 链接已损坏。有更新的链接吗?
    • 链接仍然失效
    猜你喜欢
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    • 2013-10-14
    • 2013-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-20
    相关资源
    最近更新 更多