What I do in these cases is to use a wildcard in the import-package
statement.
For example I have the following in my bnd.bnd in one of the bundles where
I use javax.xml.

> Import-Package: \
> javax.xml.bind*;version="[2.0,3)", \
> javax.xml.soap;version="[1.4,2)", \
> *
>

Regards,
João Assunção

Email: [email protected]
Mobile: +351 916968984
Phone: +351 211933149
Web: www.exploitsys.com




On Thu, Feb 9, 2023 at 2:58 PM Ephemeris Lappis <[email protected]>
wrote:

> Hello.
>
> I'm not sure my question is actually related to Karaf, but I'm sure
> Karaf users have some answers...
>
> In a bundle (blueprint) that uses camel-jaxb to process XML files, the
> manifest that is generated only sets imports for some jaxb package
> detected in the code (javax.xml.bind.annotation). It seems to be
> right.
>
> Import-Package: info.xxxxxx.yyyyy.com.caterpillar.buddy;version="[0.0,
>  1)",info.xxxxxx.yyyyy.com.facturation.facfou017.esb.enums,info.xxxxxx
>  .yyyyy.com.facturation.facfou017.esb.ficWTRV001,info.xxxxxx.yyyyy.com
>  .facturation.facturationentitefournisseur.facfou017.esb.dto,java.io,j
>  ava.lang,java.lang.invoke,java.math,java.time.format,java.time.tempor
>  al,java.util,javax.jms;version="[2.0,3)",javax.sql,javax.xml.bind.ann
>  otation;version="[2.3,3)",org.apache.camel;version="[3.20,4)",org.apa
>  che.camel.spi;version="[3.20,4)",org.apache.camel.spring.spi;version=
>  "[3.20,4)",org.apache.commons.lang3.builder;version="[3.12,4)",org.os
>  gi.service.blueprint;version="[1.0.0,2.0.0)",org.springframework.tran
>  saction
>
> The maven dependencies for the project are :
>
> info.xxxxxx.yyyyy.com.facturation:facfou017-esb:bundle:2.2.0-SNAPSHOT
> +- info.xxxxxx.yyyyy.com
> .caterpillar:caterpillar-testing:jar:0.0.1-SNAPSHOT:test
> |  +- org.liquibase:liquibase-core:jar:3.9.0:test
> |  |  \- javax.xml.bind:jaxb-api:jar:2.3.0:test
> +- org.apache.camel:camel-core:jar:3.20.2:provided
> |  +- org.apache.camel:camel-xml-jaxb:jar:3.20.2:provided
> |  |  \- com.sun.xml.bind:jaxb-impl:jar:2.3.3:provided
> +- org.apache.camel:camel-jaxb:jar:3.20.2:provided
> |  \- com.sun.xml.bind:jaxb-core:jar:2.3.0:provided
>
> So unit tests pass with no issue since the JAXP API is provided by the
> liquibase that is used for testing.
>
> But at runtime, the class javax.xml.bind.JAXBException that is caught
> in a Camel route is not found. It seems to be logical, since the
> package javax.xml.bind is not imported.
>
> I added a dynamic import on this package, and now it works.
>
> So, what is the best way to get all the needed imports ? Is the
> dynamic import the only way to add missing packages ? How can we
> detect early missing imports that maven-bundle-plugin doesn't take
> into account ?
>
> Thanks for your help.
>
> Regards.
>

Reply via email to