Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with maven built OSGi including dependencies
    text
    copied!<p>I'm currently starting with OSGi, iPOJO and iPOJO Annotations and trying to build a simple component to be deployed in Felix. Unfortunately, I'm stumbling over various problems which take me hours to solve or which I cannot even solve after wasting hours, like the following:</p> <p>I want to use an existing library in my OSGi bundle which we build using Maven. The library is currently not "OSGI-ified" and we are not planning to do so in the medium term. Because of that, I want to include this library and all of its dependencies in the bundle, using …:</p> <pre><code>&lt;Embed-Dependency&gt;*&lt;/Embed-Dependency&gt; &lt;Embed-Transitive&gt;true&lt;/Embed-Transitive&gt; </code></pre> <p>What I have now, is the following pom.xml file for the OSGi component:</p> <pre><code>&lt;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/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;foo&lt;/groupId&gt; &lt;artifactId&gt;samplecomponent&lt;/artifactId&gt; &lt;packaging&gt;bundle&lt;/packaging&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;2.3.2&lt;/version&gt; &lt;configuration&gt; &lt;compilerArgument&gt;-Xlint:all&lt;/compilerArgument&gt; &lt;showWarnings&gt;true&lt;/showWarnings&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;compilerArguments&gt; &lt;encoding&gt;UTF-8&lt;/encoding&gt; &lt;/compilerArguments&gt; &lt;showDeprecation&gt;true&lt;/showDeprecation&gt; &lt;verbose&gt;true&lt;/verbose&gt; &lt;encoding&gt;UTF-8&lt;/encoding&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.felix&lt;/groupId&gt; &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt; &lt;extensions&gt;true&lt;/extensions&gt; &lt;version&gt;2.3.6&lt;/version&gt; &lt;configuration&gt; &lt;instructions&gt; &lt;Bundle-SymbolicName&gt;${project.artifactId}&lt;/Bundle-SymbolicName&gt; &lt;Embed-Dependency&gt;*&lt;/Embed-Dependency&gt; &lt;Embed-Transitive&gt;true&lt;/Embed-Transitive&gt; &lt;Embed-Directory&gt;lib&lt;/Embed-Directory&gt; &lt;Export-Package&gt;*&lt;/Export-Package&gt; &lt;_exportcontents&gt;*&lt;/_exportcontents&gt; &lt;/instructions&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.felix&lt;/groupId&gt; &lt;artifactId&gt;maven-ipojo-plugin&lt;/artifactId&gt; &lt;version&gt;1.6.0&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;goals&gt; &lt;goal&gt;ipojo-bundle&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.felix&lt;/groupId&gt; &lt;artifactId&gt;org.apache.felix.ipojo.annotations&lt;/artifactId&gt; &lt;version&gt;1.8.0&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;foo&lt;/groupId&gt; &lt;artifactId&gt;mylibrary&lt;/artifactId&gt; &lt;version&gt;1.2.3&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/project&gt; </code></pre> <p>The bundle jar file is built without any problems, but when deploying and starting the bundle on Apache Felix, I get the following error:</p> <pre><code>g! install file:/…/samplecomponent-0.0.1-SNAPSHOT.jar Bundle ID: 8 g! start 8 org.osgi.framework.BundleException: Unresolved constraint in bundle samplecomponent [8]: Unable to resolve 8.0: missing requirement [8.0] osgi.wiring.package; (osgi.wiring.package=com.sun.jdmk.comm) </code></pre> <p>I have set the log level to the highest verbosity, no more information unfortunately. When I remove mylibrary, the bundle is started without problems.</p> <p>Any suggestions appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload