You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by jochenw <jo...@googlemail.com> on 2018/12/21 13:40:32 UTC

Karaf 4.1.7: problems finding alternative JAXB contect factory

Hello,

in our application, at one place, the eclipselink moxy library is used for
unmarshalling JSON content. The JAXB context for creating the unmarshaller
is set up in the usual way:

/jaxbContext = JAXBContext.newInstance(packageName, classLoader,
properties)/

The package with "packageName" contains a jaxb.properties file with
following entry:

/javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory/

and the eclipselink moxy library is installed and started as normal bundle
(version 2.7.1).

In the latest Karaf versions, the org.apache.servicemix.specs.jaxb-api-2.2
is under lib/endorsed, and config.properties set accordingly so the packages
from this jar are used instead of the respective JRE packages.

When creating the JAXB context, we always get the default factory, not the
one defined in the jaxb.properties file - and then setting the
"eclipselink.media-type" property of course fails. Looking bit deeper, it
seems that the ContextFinder in the javax.xml.bind package in the jaxb-api
jar combined with the OsgiLocator from the
org/apache/servicemix/specs/locator package in the same jar cannot find the
JAXB factory from eclipselink moxy, and then fall back to the default / use
the one from org.apache.servicemix.bundles.jaxb-impl-2.2.

Removing the jaxb-api jar from the lib/endorsed folder, adapting
config.properties accordingly, and installing the specs bundles "normally"
is not an option, since then the CXF feature which we use in other places
for REST interfaces does not work correctly any longer. Might be some class
path issue, but I haven't looked deeper into this.

Does somebody know a way out of this dilemma?

By the way: is there a trick to see the sources from endorsed libraries when
debugging from eclipse? By default, eclipse uses the code from the JDK,
which is of course annoying, since this is differing from the code in the
servicemix specs bundles. And taking the line numbers from eclipse and then
searching for the right place in the servicemix specs code in github is not
really comfortable .

Regards,
Jochen



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf 4.1.7: problems finding alternative JAXB contect factory

Posted by jochenw <jo...@googlemail.com>.
Hi François,

that would be great! It your sample project available somewhere in github? I
could then check whether it works in Karaf 4.1.7 and compare it to my
configuration.

Regards,
Jochen



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf 4.1.7: problems finding alternative JAXB contect factory

Posted by Francois Papon <fr...@openobject.fr>.
Hi,

I have an old project with Karaf where I'm using EclipseMoxy, I will
share it ;)

Regards,

François Papon
fpapon@apache.org

Le 21/12/2018 à 17:40, jochenw a écrit :
> Hello,
>
> in our application, at one place, the eclipselink moxy library is used for
> unmarshalling JSON content. The JAXB context for creating the unmarshaller
> is set up in the usual way:
>
> /jaxbContext = JAXBContext.newInstance(packageName, classLoader,
> properties)/
>
> The package with "packageName" contains a jaxb.properties file with
> following entry:
>
> /javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory/
>
> and the eclipselink moxy library is installed and started as normal bundle
> (version 2.7.1).
>
> In the latest Karaf versions, the org.apache.servicemix.specs.jaxb-api-2.2
> is under lib/endorsed, and config.properties set accordingly so the packages
> from this jar are used instead of the respective JRE packages.
>
> When creating the JAXB context, we always get the default factory, not the
> one defined in the jaxb.properties file - and then setting the
> "eclipselink.media-type" property of course fails. Looking bit deeper, it
> seems that the ContextFinder in the javax.xml.bind package in the jaxb-api
> jar combined with the OsgiLocator from the
> org/apache/servicemix/specs/locator package in the same jar cannot find the
> JAXB factory from eclipselink moxy, and then fall back to the default / use
> the one from org.apache.servicemix.bundles.jaxb-impl-2.2.
>
> Removing the jaxb-api jar from the lib/endorsed folder, adapting
> config.properties accordingly, and installing the specs bundles "normally"
> is not an option, since then the CXF feature which we use in other places
> for REST interfaces does not work correctly any longer. Might be some class
> path issue, but I haven't looked deeper into this.
>
> Does somebody know a way out of this dilemma?
>
> By the way: is there a trick to see the sources from endorsed libraries when
> debugging from eclipse? By default, eclipse uses the code from the JDK,
> which is of course annoying, since this is differing from the code in the
> servicemix specs bundles. And taking the line numbers from eclipse and then
> searching for the right place in the servicemix specs code in github is not
> really comfortable .
>
> Regards,
> Jochen
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html