On 4/2/10 5:35, Nicolas Delsaux wrote:
Hi all, i'm currently playing with Felix tutorial.
By use, I do it with maven projects; Tht's to say that, as an example,
I've made the translation service a maven module in my project, and
created the pom file accordingly.
As a consequence, my pom looks like this :
<project>
<parent>
<artifactId>jypsy</artifactId>
<groupId>com.mycompany</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.pss</groupId>
<artifactId>translation-english</artifactId>
<packaging>bundle</packaging>
<name>translation-english</name>
<version>0.0.1-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>com.mycompany.translation.api.*</Export-Package>
<Private-Package>com.mycompany.translation.english.*</Private-Package>
<Bundle-Activator>com.mycompany.translation.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
As one may guess, i have a superpom which eases me the task of
declaring attributes of my manifest, using the following template :
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Version>${pom.version}</Bundle-Version>
</instructions>
</configuration>
</plugin>
But there is something I don't understand : the generated manifest has
a set of import package that *precisely* contains my package classes :
Manifest-Version: 1.0
Export-Package: com.mycompany.translation.api
Private-Package: com.mycompany.translation.english
Built-By: ndx
Tool: Bnd-0.0.238
Bundle-Name: translation-english
Created-By: Apache Maven Bundle Plugin
Bundle-Vendor: mycompany
Build-Jdk: 1.6.0_16
Bundle-Version: 0.0.1.SNAPSHOT
Bnd-LastModified: 1270200175640
Bundle-ManifestVersion: 2
Bundle-Activator: com.mycompany.translation.Activator
Bundle-Description: A project
Import-Package: com.mycompany.translation,com.mycompany.translatio
n.api
Bundle-SymbolicName: com.mycompany.translation-english
Bundle-DocURL: http://www.perdu.com
And, as a consequence, when dropping that bundle in Felix, I get an exception :
ERROR: Error starting
file:/C:/java-ext/felix-framework-2.0.4/bundle/translation-english-0.0.1-SNAPSHOT.jar
(org.osgi.fr
amework.BundleException: Unresolved constraint in bundle
com.mycompany.translation-english [7]: package; (package=com.
mycompany.translation))
org.osgi.framework.BundleException: Unresolved constraint in bundle
com.mycompany.translation-english [7]: package; (p
ackage=com.mycompany.translation)->
Here I can see the generated Import-Package clause is wrong.
So, what can I do to avoid/correct that ?
Looking this info, it appears that your bundle makes reference to
package com.mycompany.translation (via its activator) but does not
contain this package, thus you get a resolve exception when you try to
start it.
Looking at your POM above, you do not include this package in
Private-Package or Export-Package, so it cannot be inside your bundle.
So, I think the import is correct since your bundle is not packaged
properly. In short, you need to add this package to your bundle if you
don't want to import it.
-> richard
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]