views:

2688

answers:

2

Hi all, I'm currently developing an OSGi based application (using Equinox) by trying to mavenize a web tutorial I've found on OSGi+Equinox. In this project, there are bundles depending on other bundles (quote-service depends on quote). The compile phase does succeed, but the package phase does not. Maven complains the following :

[INFO] [bundle:bundle]
[ERROR] Error building bundle de.vogella.osgi:quote-service:bundle:0.0.1 : Unresolved references to [de.vogella.osgi.quote] by class(es) on the Bundle-Classpath[Jar:dot]: [de/vogella/osgi/quoteservice/Activator.class, de/vogella/osgi/quoteservice/QuoteService.class]
[ERROR] Error(s) found in bundle configuration

I do understand the problem, but do not see how to make it work. This is the quote's pom :

<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"&gt;

<parent>
 <artifactId>osgi-first-app</artifactId>
 <groupId>de.vogella.osgi</groupId>
 <version>0.0.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>de.vogella.osgi</groupId>
<artifactId>quote</artifactId>
<packaging>bundle</packaging>
<name>Quote Bundle</name>
<version>0.0.1</version>

<build>
 <plugins>
  <plugin>
   <groupId>org.apache.felix</groupId>
   <artifactId>maven-bundle-plugin</artifactId>
   <version>1.4.3</version>
   <extensions>true</extensions>
   <configuration>
    <instructions>
     <_include>src/main/resources/META-INF/MANIFEST.MF</_include>
    </instructions>
   </configuration>
  </plugin>
 </plugins>
</build>
</project>

and the quote's bundle manifest :

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Quote Plug-in
Bundle-SymbolicName: de.vogella.osgi.quote
Bundle-Activator: de.vogella.osgi.quote.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: de.vogella.osgi.quote

Then the quote-service's pom :

<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"&gt;

<parent>
 <artifactId>osgi-first-app</artifactId>
 <groupId>de.vogella.osgi</groupId>
 <version>0.0.1</version>
</parent>

<dependencies>
 <dependency>
  <groupId>de.vogella.osgi</groupId>
  <artifactId>quote</artifactId>
  <version>0.0.1</version>
  <type>bundle</type>
 </dependency>
</dependencies>

<modelVersion>4.0.0</modelVersion>
<groupId>de.vogella.osgi</groupId>
<artifactId>quote-service</artifactId>
<packaging>bundle</packaging>
<name>Quote Service Bundle</name>
<version>0.0.1</version>

<build>
 <plugins>
  <plugin>
   <groupId>org.apache.felix</groupId>
   <artifactId>maven-bundle-plugin</artifactId>
   <version>1.4.3</version>
   <extensions>true</extensions>
   <configuration>
    <instructions>
     <_include>src/main/resources/META-INF/MANIFEST.MF</_include>
    </instructions>
   </configuration>
  </plugin>
 </plugins>
</build>
</project>

And finally the quote-service's manifest :

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Quoteservice Plug-in
Bundle-SymbolicName: de.vogella.osgi.quoteservice
Bundle-Activator: de.vogella.osgi.quoteservice.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.osgi.framework;version="1.3.0", \
 de.vogella.osgi.quote;version="0.0.1"

Is there something wrong ? Thank you in advance !

+6  A: 

The answer is quite simple : I removed the already defined manifest, and used bnd entries in the bundle plugin instructions. That works !

Patriarch24
Andrew Swan
+1  A: 

Tycho is designed to handle these types of problems.

Brian Fox