I wrote an OSGi bundle using "maven-bundle-plugin"(where i try to make the "jruby-complete-1.4.0.jar" as osgi bundle, note that only dependency is "jruby-complete-1.4.0.jar")..When i check the bundle via osgi console using diag command( #diag XX) it says some packages are missing;
osgi> diag 51
reference:file:dropins/jruby-complete-1.4.0.wso2v1.jar [51]
Direct constraints which are unresolved:
Missing optionally imported package com.sun.mirror.apt_0.0.0.
Missing optionally imported package com.sun.mirror.declaration_0.0.0.
Missing optionally imported package com.sun.mirror.type_0.0.0.
Missing optionally imported package com.sun.mirror.util_0.0.0.
Missing optionally imported package org.apache.bsf.util_0.0.0.
Missing optionally imported package org.jgrapht_0.0.0.
Missing optionally imported package org.jgrapht.graph_0.0.0.
Missing optionally imported package sun.misc_0.0.0.
My pom is like;
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
com.kenai.*,
com.sun.jna.*,
org.jruby.*,
org.joni.*,
</Export-Package>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Fragment-Host>bsf-all</Fragment-Host>
<DynamicImport-Package>*</DynamicImport-Package>
<Embed-Dependency>*;scope=compile|runtime;inline=true;</Embed-Dependency>
</instructions>
</configuration>
</plugin>
So, i tried add those "optional missing packages" in <Import-Package>
option as in pom[2]
But it gives more issues like;
ference:file:dropins/jruby-complete-1.4.0.wso2v1.jar [51]
Constraints from the fragment conflict with the host: Import-Package: *; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.apt; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.declaration; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.type; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.util; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: javax.management; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: javax.script; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: javax.swing.plaf.basic; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: org.apache.bsf; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: org.apache.bsf.util; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: org.jgrapht; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: org.jgrapht.graph; version="0.0.0"
Constraints from the fragment conflict with the host: Import-Package: org.jruby.anno; version="[1.4.0,2.0.0)"
Constraints from the fragment conflict with the host: Import-Package: org.jruby.exceptions; version="[1.4.0,2.0.0)"
Constraints from the fragment conflict with the host: Import-Package: org.jruby.runtime; version="[1.4.0,2.0.0)"
Constraints from the fragment conflict with the host: Import-Package: org.jruby.runtime.builtin; version="[1.4.0,2.0.0)"
Constraints from the fragment conflict with the host: Import-Package: sun.misc; version="0.0.0"
Direct constraints which are unresolved:
Missing imported package com.sun.mirror.apt_0.0.0.
Missing imported package com.sun.mirror.declaration_0.0.0.
Missing imported package com.sun.mirror.type_0.0.0.
Missing imported package com.sun.mirror.util_0.0.0.
Missing imported package org.apache.bsf.util_0.0.0.
Missing imported package org.jgrapht_0.0.0.
Missing imported package org.jgrapht.graph_0.0.0.
Missing optionally imported package org.jruby.anno_[1.4.0,2.0.0).
Missing optionally imported package org.jruby.exceptions_[1.4.0,2.0.0).
Missing optionally imported package org.jruby.runtime_[1.4.0,2.0.0).
Missing optionally imported package org.jruby.runtime.builtin_[1.4.0,2.0.0).
Missing imported package sun.misc_0.0.0.
pom.xml [2];
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
com.kenai.*,
com.sun.jna.*,
org.jruby.*,
org.joni.*,
</Export-Package>
<Import-Package>
com.sun.mirror.apt.*,
com.sun.mirror.declaration.*,
com.sun.mirror.type.*,
com.sun.mirror.util.*,
org.apache.bsf.util.*,
org.jgrapht.*,
org.jgrapht.graph.*,
sun.misc.*,
*;resolution:=optional
</Import-Package>
<Fragment-Host>bsf-all</Fragment-Host>
<DynamicImport-Package>*</DynamicImport-Package>
<Embed-Dependency>*;scope=compile|runtime;inline=true;</Embed-Dependency>
</instructions>
</configuration>
</plugin>
How can i overcome above issue? I'm exporting some packages which, i need for other bundles...Am i doing anything wrong here?
Those packages are optional imports, so there isn't necessarily any problem here.
UPDATE after poster amended question:
These dependencies have been discovered by the bundle plugin by inspecting the bytecode in your bundle. They would normally be mandatory dependencies but for some reason you have made them optional by adding <Import-Package>*;resolution:=optional</Import-Package>
. Not sure why you did that but never mind...
The proper way to resolve packages is to find a bundle that exports them. For example, your bundle needs the package org.jgrapht
. Therefore you need to install the bundle that exports that package.
The one exception is the sun.misc
package, which obviously comes from the JRE but is not supposed to be used in general. OSGi framework do not make this package available by default, but you can configure them by adding the following setting:
org.osgi.framework.system.packages.extra=sun.misc
The exact file or location to place this setting depends on your OSGi framework -- you haven't specified which one you are using, so whatever it is please check its documentation on how to pass configuration settings.