"Exporting packages that are not on the bundle classpath" for my system bundle extension fragment

1,046 views
Skip to first unread message

Dan Gravell

unread,
Oct 17, 2012, 8:29:10 AM10/17/12
to bndtool...@googlegroups.com
I have a fragment that exports additional packages from the system bundle to support various 3rd party JARs, as described here: http://blog.springsource.org/2009/01/19/exposing-the-boot-classpath-in-osgi/ (solution A').

This used to work.

Today I updated some of my other bundles (not the system bundle extension) and it no longer builds. Here's my bnd file:

Fragment-Host: system.bundle; extension:=framework
Export-Package: sun.nio.ch,\
 sun.security.action,\
 sun.misc,\
 com.sun.org.apache.xpath.internal.jaxp,\
 com.sun.management,\
 com.sun.image.codec.jpeg,\
 com.sun.medialib.mlib,\
 javax.swing,\
 sun.awt.image,\
 sun.awt.image.codec,\
 sun.security.action,\
 org.w3c.dom,\
 javax.xml.transform,\
 javax.xml.namespace,\
 com.apple.eio
Bundle-Version: 1.0.3

Here's the error message:

Exporting packages that are not on the Bundle-Classpath[Jar:dot]: [sun.security.action]

At this point the bundle is built but the Export-Package *only* contains sun.security.action... which is a little strange given the message. I thought it would be the inverse!

If I remove the sun.security.action then I get the following three warnings:

1)
Instructions in Export-Package that are never used: javax\.xml\.namespace
                sun\.nio\.ch
                com\.apple\.eio
                sun\.misc
                sun\.awt\.image
                org\.w3c\.dom
                javax\.xml\.transform
                sun\.security\.action
                com\.sun\.image\.codec\.jpeg
                com\.sun\.org\.apache\.xpath\.internal\.jaxp
                javax\.swing
                com\.sun\.medialib\.mlib
                com\.sun\.management
                sun\.awt\.image\.codec
Classpath: Jar:com.elsten.bliss.osgi.system

2)
Superfluous export-package instructions: [com.sun.management, sun.awt.image, com.sun.medialib.mlib, org.w3c.dom, javax.xml.namespace, com.sun.org.apache.xpath.internal.jaxp, sun.security.action, com.sun.image.codec.jpeg, javax.swing, javax.xml.transform, sun.awt.image.codec, sun.nio.ch, sun.misc, com.apple.eio

3)
Unknown directive extension: in Fragment-Host, allowed directives are resolution:, and 'x-*'

And no Export-Package ends up in the MANIFEST.

bndtools v1.0 this time...

Anybody have any ideas? Tried cleaning, rebuilding, closing project, opening, restarting Eclipse. The packages appear in rt.jar (at least, the one I think it's using).

Dan

Neil Bartlett

unread,
Oct 17, 2012, 8:53:44 AM10/17/12
to bndtool...@googlegroups.com
It's possible that you just have an error in the format of the bnd file, e.g. a trailing space after one of the backslashes perhaps. Can you post it as an attachment?

Regards
Neil

Dan Gravell

unread,
Oct 17, 2012, 9:07:04 AM10/17/12
to bndtool...@googlegroups.com
More than possible :)

I cannot attach a file (Google Groups error #340) but I've uploaded it to Dropbox: http://dl.dropbox.com/u/6134049/bnd.bnd

Dan

Derek Baum

unread,
Oct 18, 2012, 4:14:33 AM10/18/12
to bndtool...@googlegroups.com
The version of bnd included with my bndtools-1.0 is 1.51.1, and this looks broken with respect to fragment host directives:

Here's part of OSGI-OPT/src/aQute/lib/osgi/Verifier.java from the 1.51.1 bnd.jar:

Notice that it specifies that Fragment-Host has a directive "resolution:", the latest version of bnd specifies:
verifyDirectives("Fragment-Host", "extension:", SYMBOLICNAME, "bsn");

    public void verify() throws Exception {
        if (classSpace == null)
            classSpace = analyzeBundleClasspath(dot,
                    parseHeader(getHeader(Analyzer.BUNDLE_CLASSPATH)),
                    contained, referred, uses);


        verifyDirectives("Export-Package", "uses:|mandatory:|include:|exclude:|" + IMPORT_DIRECTIVE);
        verifyDirectives("Import-Package", "resolution:");
        verifyDirectives("Require-Bundle", "visibility:|resolution:");
        verifyDirectives("Fragment-Host", "resolution:");
        verifyDirectives("Provide-Capability", "effective:|uses:");
        verifyDirectives("Require-Capability", "effective:|resolve:|filter:");
        verifyDirectives("Bundle-SymbolicName", "singleton:|fragment-attachment:|mandatory:");

--
Derek

Dan Gravell

unread,
Oct 18, 2012, 12:27:35 PM10/18/12
to bndtool...@googlegroups.com, de...@baums.org.uk
Thanks Derek. This is strange, because I'm pretty certain this was working before.

Is there any way to force the Export-Package declarations through to the manifest? Aside from the lack of the Export-Package packages, the manifest is otherwise generated correctly.

Dan

Peter Kriens

unread,
Oct 22, 2012, 4:32:14 AM10/22/12
to bndtool...@googlegroups.com, de...@baums.org.uk
Try using EXPORT-PACKAGE instead of Export-Package. bnd is case sensitive but OSGi isnt. bnd is just telling you that the given classes cannot be found on the given classpath. bnd does not see rt.jar unless it is specifically added to its class path. Since you're not verifying anything anyway, bnd could stay out of the way.

You can also specify -failok: true to ignore the error.

Kind regards,

Peter Kriens

Dan Gravell

unread,
Nov 12, 2012, 9:47:55 AM11/12/12
to bndtool...@googlegroups.com, de...@baums.org.uk
This appeared to get me further, thanks. The error marker still appears in bndtools but at least the EXPORT-PACKAGE is now generated in the bundle.

Dan
Reply all
Reply to author
Forward
0 new messages