4

I want to create a very simple (Hello Simple World) POC that demonstrates the ability to integrate OSGi (Felix) with Scala and Actors (Akka). Here is what I have so far:

$ 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)

I understand from this error message that there is no bundle that exports osgi.wiring.package. But I don't know which bundle I would need to include that exports that package. Would it come from Akka, from Felix, or from somewhere else?

As can be seen in the provided config.properties I tried to follow the instructions about how to Configure the OSGi Framework from the akka documentation, but I don't know if I'm doing what they said needs to be done in the right way.

The akka documentation says:

To use Akka in an OSGi environment, the org.osgi.framework.bootdelegation property must be set to always delegate the sun.misc package to the boot classloader instead of resolving it through the normal OSGi class space.

How do you do this using Felix as the OSGi container, and using the default felix launcher?

A simple hello world example using OSGi (Felix is not required, but preferred) and Akka Actors is ideally what I'm looking for. If you know of anything on github (or elsewhere) that demonstrates this, I would accept that as an answer too.

4

3 回答 3

4

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

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

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

于 2013-11-06T19:49:08.337 回答
1

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

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

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

于 2018-04-10T13:39:17.567 回答
-3

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

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

最好的问候安德烈亚斯

于 2014-03-20T11:48:56.107 回答