javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package {0}

In my solution, I use JAXB to convert from XML over the wire into Java objects. I added the JAXB jars to my ear (as previously explained). When I deployed and tested the solution on my local server everything was fine.

When I deployed and tested the solution on the development machine, which contains WebSphere Application Server and the Oracle BPEL container, it didn’t work and threw the following exception:

javax.xml.bind.JAXBException: Unable 
to locate jaxb.properties for package com.twc.logging

This exception is very strange because the xjc compiler that I use to generate the JAXB classes from an XSD definition doesn’t generate a ‘jaxb.properties’. A search on google turned up?
the JAXB FAQ :
A thread on the sun java forums

The JAXB FAQ contains instructions to set the appropriate classloader so that the file can be found. I did this but it didn’t resolve my problem.

As I continued to scour the internet, it was strongly hinted that this was a required properties file in version 1.0 but is not present in 2.0. I decided to fire up my new best friend, Which4J to figure out which classloader was picking up the JAXB classes.

Sure enough, it turned out that there was an implementation of JAXB contained inside an oracle jar called ‘xml.jar’. Of course, the oracle container installed itself in the system classloader, so all of it’s jars are always on the classpath of all applications all the time. This means that no application that exploits JAXB 2.0 can be installed on the server.

We have a ticket open with oracle.

And since I’m on the topic of JAXB, the Unmarshaller is NOT thread-safe. I tried to save a line of code by storing it as a static reference in my class until my colleague pointed that fact out to me.

Author: dan

Comments

  1. Thanks a lot.. after going thru ur article I was able to decipher the issue i was facing bcos of jar which support JAXB1.0 and i was using xjc for JAXB2.0

  2. Hi
    I have run into the same issue. Using JAXB 2.0 for xjc and standalone junit works like a dream. But when deploying to oc4j ,the JAXB 1.0 is loaded from ORACLE_HOME/lib/xml.jar.

    I realize this posting was done 1.5 yrs back, but could you give info on the ticket opened towards Oracle, so that I can look into the response.

    Would it be possible to have a JAXB 2.0 application execute within oc4j 10.1.3.* without messing up the container classpath

Leave a Reply

Your email address will not be published. Required fields are marked *