Вопрос

Simple experiment -

bundle A needs some com.sun.xml.internal.bind classes to be available to it via it's class loader ( jaxb.. )

I googled my way to the theoretical solution of forcing system.bundle to export com.sun.xml.internal.bind by adding the package to "org.osgi.framework.system.packages.extra" ( a standard framework parameter implemented in felix, documented at http://felix.apache.org/site/apache-felix-framework-configuration-properties.html ) and importing it in my bundle.

By doing so the bundle would not resolve anymore..

Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (osgi.wiring.package=com.sun.xml.internal.bind)

( 5 is the jaxb-using bundle ) Setting "org.osgi.framework.bootdelegation" for "com.sun.xml.internal.bind" and not importing it in the dependent bundle worked as documented.

Am i misinterpreting what system.packages.extra should do? Can i just not resolve imports from system.bundle? I tried explicitly setting system.bundle in the import via bnd at the bottom of my Import-Package directive

com.sun.xml.internal.bind;bundle-symbolic-name="system.bundle",\
*

Which resulted in

Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (&(osgi.wiring.package=com.sun.xml.internal.bind)(bundle-symbolic-name=system.bundle))

ps: i'm using bnd and the -runproperties to define these. My bndrun file has:

-runproperties: osgi.console.enable.builtin=true,\
com.mycompany.manager.confDir=./etc,\
org.osgi.framework.system.packages.extra=com.sun.xml.internal.bind,\
org.osgi.service.http.port=8888

the bundle that needs jaxb defines the following import

Import-Package: com.sun.xml.internal.bind,\
    *

When trying to resolve dependencies in the bndrun editor, i get

    Unable to resolve <<INITIAL>> ver=null: missing requirement (osgi.identity=com.mycompany.configuration.jaxb) [caused by: Unable to resolve com.mycompany.configuration.jaxb ver=0.0.0: missing requirement (osgi.wiring.package=com.sun.xml.internal.bind)]
org.osgi.service.resolver.ResolutionException: Unable to resolve <<INITIAL>> ver=null: missing requirement (osgi.identity=com.mycompany.configuration.jaxb) [caused by: Unable to resolve com.mycompany.configuration.jaxb ver=0.0.0: missing requirement (osgi.wiring.package=com.sun.xml.internal.bind)]
    at org.apache.felix.resolver.Candidates.populateResource(Candidates.java:285)
    at org.apache.felix.resolver.Candidates.populate(Candidates.java:153)
    at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:148)
    at biz.aQute.resolve.ResolveProcess.resolveRequired(ResolveProcess.java:34)
    at org.bndtools.core.resolve.ResolveOperation.run(ResolveOperation.java:61)
    at org.bndtools.core.resolve.ResolveJob.run(ResolveJob.java:43)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Это было полезно?

Решение

I see you are using Bndtools. Good! We have a special property for setting the system packages from the .bndrun file:

-runsystempackages: com.sun.xml.internal.bind

I'm not sure why it didn't work when you put this inside -runproperties... possibly just a typo though I haven't been able to spot it. Anyway it's better to use -runsystempackages because then the Bndrun resolver also knows to add these packages to the system bundle; then you'll be able to resolve in the bndrun editor as well.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top