JAXB Providers Specified In javax.xml.bind.JAXBContext Is Not Working In WebLogic 12c
(Doc ID 1502967.1)
Last updated on MAY 30, 2024
Applies to:
Oracle WebLogic Server - Version 12.1.1.0 and laterInformation in this document applies to any platform.
Symptoms
When creating a JAXBContext.newInstance() using JDK JAXBContext class. WebLogic Server throws JAXBException.
Loading a custom JAXBContext inside the war under the location /app.war/META-INF/services/javax.xml.bind.JAXBContext
The file contains the JDK class "com.sun.xml.internal.bind.v2.ContextFactory"
Discovery of JAXB implementation
When one of the newInstance methods is called, a JAXB implementation is discovered by the following steps.
- For each package/class explicitly passed in to the newInstance(java.lang.String) method, in the order they are specified, jaxb.properties file is looked up in its package, by using the associated classloader — this is
the owner class loader
for aClass
argument, and for a package the speifiedClassLoader
.If such a file is discovered, it is
loaded
as a property file, and the value of the JAXB_CONTEXT_FACTORYkey will be assumed to be the provider factory class. This class is then loaded by the associated classloader discussed above.This phase of the look up allows some packages to force the use of a certain JAXB implementation. (For example, perhaps the schema compiler has generated some vendor extension in the code.)
- If the system property
JAXB_CONTEXT_FACTORY
exists, then its value is assumed to be the provider factory class. This phase of the look up enables per-JVM override of the JAXB implementation. - Look for /META-INF/services/javax.xml.bind.JAXBContext file in the associated classloader. This file follows the standard service descriptor convention, and if such a file exists, its content is assumed to be the provider factory class. This phase of the look up is for automatic discovery. It allows users to just put a JAXB implementation in a classpath and use it without any further configuration.
- Finally, if all the steps above fail, then the rest of the look up is unspecified. That said, the recommended behavior is to simply look for some hard-coded platform default JAXB implementation. This phase of the look up is so that JavaSE can have its own JAXB implementation as the last resort.
It seems as the JAXB implementation in WebLogic 12c has a problem. For instance, JAXBContext in JDK has a logic to override javax.xml.bind.context.factory by the class name in the file META-INF/services/javax.xml.bind.JAXBContext, but WebLogic 12c seems not process that file.
The application worked fine in older versions of WLS but not in WebLogic 12c. The code also works fine in the standalone JDK, both jdk1.6.0_33 and jdk150_04.
Changes
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Discovery of JAXB implementation |
Changes |
Cause |
Solution |