Akka OSGi / Aries / 2.10.0-RC3 versions
As per request I am creating this ticket from the discussion in the mailing list.
Essentially I needed to change the bundle manifest in one of the Akka bundles to get the Aries Blueprint support running in my container:
I ll try to find time to upload the test case, but for some reason, scalatest didn't work in pax-exam for me. I ll revisit that as soon as i find time.
Andreas
From the thread :
---->> snip
Hi Roland,
I have changed the manifest of the bundle akka-osgi-aries by removing the import package for org.apache.aries.blueprint.reflect.
I spent some time yesterday looking for that particular package as it was in the original manifest as in imported package.
The package is in the library of org.apache.aries.blueprint/org.apache.aries.blueprint/0.4, but it is not exported. Looking at the code,
I believe that is correct as that package only contains Implementation classes and IMHO shouldn't be exported.
This is why I have tried to fix it by modifying the manifest and remove the package, which did the trick for me.
Perhaps I was using the wrong bundle combination in terms of versions, but earlier versions of blueprint also did not export that package.
As for fixing it: Depending on what you use for generating your manifests, sometime a misplaced import statement generates wrong import package, which might have happened in that case. I got bitten by that a million times or more.
For completeness, my manifest is now:
Manifest-Version: 1.0
Bnd-LastModified: 1353971408960
Bundle-ManifestVersion: 2
Bundle-Name: com.typesafe.akka.osgi.aries
Bundle-SymbolicName: com.typesafe.akka.osgi.aries
Bundle-Version: 2.1.0.RC3
Created-By: 1.6.0_35 (Apple Inc.)
Import-Package: akka.actor;version="[2.1,2.2)",akka.osgi;version="[2.1,2
.2)",com.typesafe.config;version="[0.4.1,1.1.0)",org.apache.aries.bluep
rint;version="[0.3,1)",org.apache.aries.blueprint.mutable;version="[0.3
,1)",org.osgi.framework;version="[1.5,2)",org.osgi.service.blueprint.co
ntainer;version="[1.0,2)",org.osgi.service.blueprint.reflect;version="[
1.0,2)",org.w3c.dom,scala;version="[2.10,2.11)",scala.collection;versio
n="[2.10,2.11)",scala.collection.generic;version="[2.10,2.11)",scala.co
llection.immutable;version="[2.10,2.11)",scala.collection.mutable;versi
on="[2.10,2.11)",scala.reflect;version="[2.10,2.11)",scala.runtime;vers
ion="[2.10,2.11)"
Include-Resource: /Users/viktorklang/Documents/workspace/akka/akka/akka-
osgi-aries/src/main/resources,/Users/viktorklang/Documents/workspace/ak
ka/akka/akka-osgi-aries/target/resource_managed/main
Private-Package: akka.osgi.aries.blueprint
Tool: Bnd-1.50.0
And I am using the following pax-runner configuration to start up my test container (this only works for me if the version of akka-osgi-aries in the local maven repo has my modified manifest).
scan-bundle:mvn:net.sourceforge.cglib/com.springsource.net.sf.cglib/2.2.0
scan-bundle:mvn:org.slf4j/slf4j-api/1.6.4
scan-bundle:mvn:org.slf4j/slf4j-simple/1.6.4
scan-bundle:mvn:org.apache.felix/org.apache.felix.configadmin/1.2.8
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0
scan-bundle:mvn:org.ops4j.pax.url/pax-url-wrap/1.2.5
scan-bundle:mvn:org.ops4j.pax.url/pax-url-mvn/1.2.5
scan-bundle:mvn:org.apache.aries/org.apache.aries.util/0.4
scan-bundle:mvn:org.apache.aries.blueprint/org.apache.aries.blueprint/0.4
scan-bundle:mvn:org.apache.aries.proxy/org.apache.aries.proxy/0.4
scan-bundle:wrap:mvn:org.scala-lang/scala-library/2.10.0-RC3$Bundle-SymbolicName=Scala&Bundle-Version=2.10&Export-Package=*;version=2.10
scan-bundle:mvn:com.typesafe/config/1.0.0
scan-bundle:mvn:com.typesafe.akka/akka-actor_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi-aries_2.10.0-RC3/2.1.0-RC3
I am happy to test another version / combination of versions if you want me to, but as far as I understand I am now using the versions Victor suggested earlier in the thread. If you are interested I can also provide a test case that would should the faulty behavior.
---<< snap
Essentially I needed to change the bundle manifest in one of the Akka bundles to get the Aries Blueprint support running in my container:
I ll try to find time to upload the test case, but for some reason, scalatest didn't work in pax-exam for me. I ll revisit that as soon as i find time.
Andreas
From the thread :
---->> snip
Hi Roland,
I have changed the manifest of the bundle akka-osgi-aries by removing the import package for org.apache.aries.blueprint.reflect.
I spent some time yesterday looking for that particular package as it was in the original manifest as in imported package.
The package is in the library of org.apache.aries.blueprint/org.apache.aries.blueprint/0.4, but it is not exported. Looking at the code,
I believe that is correct as that package only contains Implementation classes and IMHO shouldn't be exported.
This is why I have tried to fix it by modifying the manifest and remove the package, which did the trick for me.
Perhaps I was using the wrong bundle combination in terms of versions, but earlier versions of blueprint also did not export that package.
As for fixing it: Depending on what you use for generating your manifests, sometime a misplaced import statement generates wrong import package, which might have happened in that case. I got bitten by that a million times or more.
For completeness, my manifest is now:
Manifest-Version: 1.0
Bnd-LastModified: 1353971408960
Bundle-ManifestVersion: 2
Bundle-Name: com.typesafe.akka.osgi.aries
Bundle-SymbolicName: com.typesafe.akka.osgi.aries
Bundle-Version: 2.1.0.RC3
Created-By: 1.6.0_35 (Apple Inc.)
Import-Package: akka.actor;version="[2.1,2.2)",akka.osgi;version="[2.1,2
.2)",com.typesafe.config;version="[0.4.1,1.1.0)",org.apache.aries.bluep
rint;version="[0.3,1)",org.apache.aries.blueprint.mutable;version="[0.3
,1)",org.osgi.framework;version="[1.5,2)",org.osgi.service.blueprint.co
ntainer;version="[1.0,2)",org.osgi.service.blueprint.reflect;version="[
1.0,2)",org.w3c.dom,scala;version="[2.10,2.11)",scala.collection;versio
n="[2.10,2.11)",scala.collection.generic;version="[2.10,2.11)",scala.co
llection.immutable;version="[2.10,2.11)",scala.collection.mutable;versi
on="[2.10,2.11)",scala.reflect;version="[2.10,2.11)",scala.runtime;vers
ion="[2.10,2.11)"
Include-Resource: /Users/viktorklang/Documents/workspace/akka/akka/akka-
osgi-aries/src/main/resources,/Users/viktorklang/Documents/workspace/ak
ka/akka/akka-osgi-aries/target/resource_managed/main
Private-Package: akka.osgi.aries.blueprint
Tool: Bnd-1.50.0
And I am using the following pax-runner configuration to start up my test container (this only works for me if the version of akka-osgi-aries in the local maven repo has my modified manifest).
scan-bundle:mvn:net.sourceforge.cglib/com.springsource.net.sf.cglib/2.2.0
scan-bundle:mvn:org.slf4j/slf4j-api/1.6.4
scan-bundle:mvn:org.slf4j/slf4j-simple/1.6.4
scan-bundle:mvn:org.apache.felix/org.apache.felix.configadmin/1.2.8
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0
scan-bundle:mvn:org.ops4j.pax.url/pax-url-wrap/1.2.5
scan-bundle:mvn:org.ops4j.pax.url/pax-url-mvn/1.2.5
scan-bundle:mvn:org.apache.aries/org.apache.aries.util/0.4
scan-bundle:mvn:org.apache.aries.blueprint/org.apache.aries.blueprint/0.4
scan-bundle:mvn:org.apache.aries.proxy/org.apache.aries.proxy/0.4
scan-bundle:wrap:mvn:org.scala-lang/scala-library/2.10.0-RC3$Bundle-SymbolicName=Scala&Bundle-Version=2.10&Export-Package=*;version=2.10
scan-bundle:mvn:com.typesafe/config/1.0.0
scan-bundle:mvn:com.typesafe.akka/akka-actor_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi-aries_2.10.0-RC3/2.1.0-RC3
I am happy to test another version / combination of versions if you want me to, but as far as I understand I am now using the versions Victor suggested earlier in the thread. If you are interested I can also provide a test case that would should the faulty behavior.
---<< snap
Leave a comment
on 2012-12-13 22:22 *
By andreas.woq
Hello,
I have been able to create a test case based on pax-exam and scalatest:
you can use the following pax-exam composite spec:
scan-bundle:mvn:net.sourceforge.cglib/com.springsource.net.sf.cglib/2.2.0
scan-bundle:mvn:org.slf4j/slf4j-api/1.6.4
scan-bundle:mvn:org.slf4j/slf4j-simple/1.6.4
scan-bundle:mvn:org.apache.felix/org.apache.felix.configadmin/1.2.8
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0
scan-bundle:mvn:org.ops4j.pax.url/pax-url-wrap/1.2.5
scan-bundle:mvn:org.ops4j.pax.url/pax-url-mvn/1.2.5
scan-bundle:wrap:mvn:org.scala-lang/scala-library/2.10.0-RC3$Bundle-SymbolicName=Scala&Bundle-Version=2.10&Export-Package=*;version=2.10
scan-bundle:mvn:de.yconx.3rdparty/de.yconx.3rdparty.scalatest/2.0.M5-B1
scan-bundle:mvn:org.apache.aries/org.apache.aries.util/0.4
scan-bundle:mvn:org.apache.aries.blueprint/org.apache.aries.blueprint/0.4
scan-bundle:mvn:org.apache.aries.proxy/org.apache.aries.proxy/0.4
scan-bundle:mvn:com.typesafe/config/1.0.0
scan-bundle:mvn:com.typesafe.akka/akka-actor_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi-aries_2.10.0-RC3/2.1.0-RC3
please note, that I had to repackge the scalatest bundle so that it can be loaded correctly. I have posted this in the Scalatest users group, but the post hasn't been approved yet.
The following pom file allows repackages the scalatest plugin:
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2009-2011, Yconx GmbH, Fireboard GmbH.
~ All rights reserved.
~
~ SVN : $URL$
~ Last Changed : $Date$
~ By Author : $Author$
~ Last Commit Revision : $Rev$
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.yconx.3rdparty</groupId>
<artifactId>de.yconx.3rdparty.scalatest</artifactId>
<version>2.0.M5-B1</version>
<packaging>bundle</packaging>
<properties>
<pkgGroupId>org.scalatest</pkgGroupId>
<pkgArtifactId>scalatest_2.10.0-RC3</pkgArtifactId>
<pkgVersion>2.0.M5-B1</pkgVersion>
<export.package>org.scalatest*</export.package>
<import.package>
com*;resolution:=optional,org*;resolution:=optional
</import.package>
<non-import.package>
org.scalatest
</non-import.package>
</properties>
<dependencies>
<dependency>
<groupId>${pkgGroupId}</groupId>
<artifactId>${pkgArtifactId}</artifactId>
<version>${pkgVersion}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>${pkgGroupId}:${pkgArtifactId}</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>${pkgGroupId}:${pkgArtifactId}</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
</filters>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.1.0</version>
<configuration>
<manifestLocation>target/classes/META-INF</manifestLocation>
<instructions>
<Export-Package>!*.internal,!*internal.*,${export.package}</Export-Package>
<Import-Package>${import.package},*</Import-Package>
<Bundle-ManifestVersion>2.0</Bundle-ManifestVersion>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Bundle-Vendor>${project.organization.name}</Bundle-Vendor>
</instructions>
</configuration>
</plugin>
</plugins>
</build>*
Finally, here is the test case. I am simply checking wether all configured bundles that are not fragments are actually started. There may be more elegant ways of doing this, but the test case shows the error.
package de.woq.osgi
import org.junit.runner.RunWith
import org.ops4j.pax.exam.junit.{JUnit4TestRunner, Configuration, ExamFactory}
import org.osgi.framework.{Bundle, BundleContext}
import javax.inject.Inject
import org.ops4j.pax.exam.container.`def`.internal.PaxRunnerTestContainerFactory
import org.junit.{Assert, Test}
import org.scalatest.{Args, Reporter, WordSpec}
import org.scalatest.matchers.MustMatchers
import org.osgi.service.packageadmin.PackageAdmin
import org.scalatest.events.Event
@RunWith(classOf[JUnit4TestRunner])
@ExamFactory(classOf[PaxRunnerTestContainerFactory])
class SimpleOSGISpec extends Reporter {
@Inject
var context: BundleContext = null
@Configuration
def config = {
import org.ops4j.pax.exam.CoreOptions._
options(
equinox(),
junitBundles(),
scanComposite("classpath:scala.composite")
)
}
// TODO: beautify this
def apply(event: Event) {
println("Received event: " + event.toString)
}
@Test
def simpleTest {
val spec = new WordSpec with MustMatchers {
"Container" should {
"start all configured bundles that are not fragments" in {
val pkgAdmin : PackageAdmin = context.getService(context.getServiceReference(classOf[PackageAdmin]))
def isFragment(bundle: Bundle) = {
val bundles = pkgAdmin.getHosts(bundle)
bundles != null && bundles.length > 0
}
context must not equal(null)
context.getBundles foreach { bundle =>
if (!isFragment(bundle))
bundle.getState must equal(Bundle.ACTIVE)
}
}
}
}
val status = spec.run(None, new Args(this))
status.waitUntilCompleted();
Assert.assertTrue(status.isCompleted && status.succeeds)
}
}
I hope this helps
Andreas
I have been able to create a test case based on pax-exam and scalatest:
you can use the following pax-exam composite spec:
scan-bundle:mvn:net.sourceforge.cglib/com.springsource.net.sf.cglib/2.2.0
scan-bundle:mvn:org.slf4j/slf4j-api/1.6.4
scan-bundle:mvn:org.slf4j/slf4j-simple/1.6.4
scan-bundle:mvn:org.apache.felix/org.apache.felix.configadmin/1.2.8
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0
scan-bundle:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0
scan-bundle:mvn:org.ops4j.pax.url/pax-url-wrap/1.2.5
scan-bundle:mvn:org.ops4j.pax.url/pax-url-mvn/1.2.5
scan-bundle:wrap:mvn:org.scala-lang/scala-library/2.10.0-RC3$Bundle-SymbolicName=Scala&Bundle-Version=2.10&Export-Package=*;version=2.10
scan-bundle:mvn:de.yconx.3rdparty/de.yconx.3rdparty.scalatest/2.0.M5-B1
scan-bundle:mvn:org.apache.aries/org.apache.aries.util/0.4
scan-bundle:mvn:org.apache.aries.blueprint/org.apache.aries.blueprint/0.4
scan-bundle:mvn:org.apache.aries.proxy/org.apache.aries.proxy/0.4
scan-bundle:mvn:com.typesafe/config/1.0.0
scan-bundle:mvn:com.typesafe.akka/akka-actor_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi_2.10.0-RC3/2.1.0-RC3
scan-bundle:mvn:com.typesafe.akka/akka-osgi-aries_2.10.0-RC3/2.1.0-RC3
please note, that I had to repackge the scalatest bundle so that it can be loaded correctly. I have posted this in the Scalatest users group, but the post hasn't been approved yet.
The following pom file allows repackages the scalatest plugin:
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2009-2011, Yconx GmbH, Fireboard GmbH.
~ All rights reserved.
~
~ SVN : $URL$
~ Last Changed : $Date$
~ By Author : $Author$
~ Last Commit Revision : $Rev$
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.yconx.3rdparty</groupId>
<artifactId>de.yconx.3rdparty.scalatest</artifactId>
<version>2.0.M5-B1</version>
<packaging>bundle</packaging>
<properties>
<pkgGroupId>org.scalatest</pkgGroupId>
<pkgArtifactId>scalatest_2.10.0-RC3</pkgArtifactId>
<pkgVersion>2.0.M5-B1</pkgVersion>
<export.package>org.scalatest*</export.package>
<import.package>
com*;resolution:=optional,org*;resolution:=optional
</import.package>
<non-import.package>
org.scalatest
</non-import.package>
</properties>
<dependencies>
<dependency>
<groupId>${pkgGroupId}</groupId>
<artifactId>${pkgArtifactId}</artifactId>
<version>${pkgVersion}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>${pkgGroupId}:${pkgArtifactId}</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>${pkgGroupId}:${pkgArtifactId}</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
</filters>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.1.0</version>
<configuration>
<manifestLocation>target/classes/META-INF</manifestLocation>
<instructions>
<Export-Package>!*.internal,!*internal.*,${export.package}</Export-Package>
<Import-Package>${import.package},*</Import-Package>
<Bundle-ManifestVersion>2.0</Bundle-ManifestVersion>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Bundle-Vendor>${project.organization.name}</Bundle-Vendor>
</instructions>
</configuration>
</plugin>
</plugins>
</build>*
Finally, here is the test case. I am simply checking wether all configured bundles that are not fragments are actually started. There may be more elegant ways of doing this, but the test case shows the error.
package de.woq.osgi
import org.junit.runner.RunWith
import org.ops4j.pax.exam.junit.{JUnit4TestRunner, Configuration, ExamFactory}
import org.osgi.framework.{Bundle, BundleContext}
import javax.inject.Inject
import org.ops4j.pax.exam.container.`def`.internal.PaxRunnerTestContainerFactory
import org.junit.{Assert, Test}
import org.scalatest.{Args, Reporter, WordSpec}
import org.scalatest.matchers.MustMatchers
import org.osgi.service.packageadmin.PackageAdmin
import org.scalatest.events.Event
@RunWith(classOf[JUnit4TestRunner])
@ExamFactory(classOf[PaxRunnerTestContainerFactory])
class SimpleOSGISpec extends Reporter {
@Inject
var context: BundleContext = null
@Configuration
def config = {
import org.ops4j.pax.exam.CoreOptions._
options(
equinox(),
junitBundles(),
scanComposite("classpath:scala.composite")
)
}
// TODO: beautify this
def apply(event: Event) {
println("Received event: " + event.toString)
}
@Test
def simpleTest {
val spec = new WordSpec with MustMatchers {
"Container" should {
"start all configured bundles that are not fragments" in {
val pkgAdmin : PackageAdmin = context.getService(context.getServiceReference(classOf[PackageAdmin]))
def isFragment(bundle: Bundle) = {
val bundles = pkgAdmin.getHosts(bundle)
bundles != null && bundles.length > 0
}
context must not equal(null)
context.getBundles foreach { bundle =>
if (!isFragment(bundle))
bundle.getState must equal(Bundle.ACTIVE)
}
}
}
}
val status = spec.run(None, new Args(this))
status.waitUntilCompleted();
Assert.assertTrue(status.isCompleted && status.succeeds)
}
}
I hope this helps
Andreas
file:c0OKYYrrCr4RXAacwqjQYw
pom file as mentioned above
pom file as mentioned above
file:dxSeZ0rrCr4OW1acwqjQYw
Pax Runner Spec as mentioned above
Pax Runner Spec as mentioned above
file:dYQ7herrCr4RXAacwqjQYw
Test case as mentioned above
Test case as mentioned above
on 2012-12-13 22:27 *
By andreas.woq
Hi
I have attached the files, please ignore the pasted versions.
Andreas
I have attached the files, please ignore the pasted versions.
Andreas