Subject Re: [Firebird-Java] Jaybird 3.0.0-beta-3 EncodingFactory$DefaultEncodingFactory error
Author Mark Rotteveel
On 13-3-2017 15:59, 'William L. Thomson Jr.' wlt-ml@...
[Firebird-Java] wrote:
> On Monday, March 13, 2017 4:34:45 AM EDT you wrote:
>> Classloading issues are my favorite. Why does Netbeans have its own copy
>> of JAXB, when it is included in Java?!
>
> Not really sure, seems to be an older one 2.2.5. Looks like it was using a
> newer version than JDK 7 but not as new as JDK 8 which I am using, 2.2.8.
> https://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding#Versions
>
> Looks like 2.2.5 is for older JDKs as it has activation.jar. There is also a
> Jaxb-Endorsed that just has jaxb-api.jar. The other has several jars.
>
> Might be able to stop using it by removing it from Libraries. I will have to
> experiment to confirm. Though maybe required by Netbeans to operate, not sure.

Apparently the default behavior of JAXB is to use the context
classloader by default, not the classloader of the specified class(es).
I have found a solution to the problem by replacing:

JAXBContext ctx = JAXBContext.newInstance(Encodings.class);

with:

JAXBContext ctx =
JAXBContext.newInstance(ObjectFactory.class.getPackage().getName(),
ObjectFactory.class.getClassLoader());

(where ObjectFactory is the JAXB ObjectFactory in the same package as
Encodings)

I will publish a snapshot shortly.

Mark
--
Mark Rotteveel