Question

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.

Was it helpful?

Solution

There is a sample OSGi application in the Akka source tree. Hopefully you can use it as a staring point. It uses Karaf.

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

Make sure to check out the code at a stable tag, like v2.2.3 so the build tools use published stable artifacts of Akka.

OTHER TIPS

missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=com.typesafe.config)

From this part of your error message it seems that your bundle cannot find another bundle that provides com.typesafe.config which is a dependency of akka.

You can circumvent this with the Conditional-Package Header/Instruction of the bnd tool when you create your bundle.

I have started to put an OSGi container based on Karaf together and have shared it on github. For now it simply registers an ActorSystem as a service and has a demo bundle with an Actor in it using that system. It is configured to log into the normal karaf.log.

The code example can be found on github.

Best regards Andreas

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top