You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The latest javadoc of JAXBContext class specify how to use a system property to define the JAXB context Factory :
Discovery of JAXB implementation
When one of the newInstance methods is called, a JAXB implementation is discovered by the following steps.
...
2. 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.
...
The javax.xml.bind.JAXBContext.JAXB_CONTEXT_FACTORY value is "javax.xml.bind.context.factory".
It simply does not work as specified because the static method ContextFinder.find(...) is incorrect :
final String jaxbContextFQCN = JAXBContext.class.getName();
...
logger.fine("Searching the system property");
// search for a system property second (javax.xml.bind.JAXBContext)
factoryClassName = AccessController.doPrivileged(new GetPropertyAction(jaxbContextFQCN));
if( factoryClassName != null )
As a workaround, I use this particular value "javax.xml.bind.JAXBContext" at runtime to specify which JAXB implementation I want :
/** JAXB 2 Context Factory (System property) instead of "javax.xml.bind.context.factory" */
public static final String JAXB_CONTEXT_FACTORY = "javax.xml.bind.JAXBContext";
/** JAXB implementation 2.1.12 */
public static final String JAXB_CONTEXT_FACTORY_IMPLEMENTATION = "com.sun.xml.bind.v2.ContextFactory";
...
// Define the system property to define which JAXB implementation to use :
System.setProperty(JAXB_CONTEXT_FACTORY, JAXB_CONTEXT_FACTORY_IMPLEMENTATION);
@glassfishrobot Commented
snajper said:
Fixed, first the documented property is being looked at, the current way is kept still for compatibility reasons.
The latest javadoc of JAXBContext class specify how to use a system property to define the JAXB context Factory :
Discovery of JAXB implementation
When one of the newInstance methods is called, a JAXB implementation is discovered by the following steps.
...
2. 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.
...
The javax.xml.bind.JAXBContext.JAXB_CONTEXT_FACTORY value is "javax.xml.bind.context.factory".
It simply does not work as specified because the static method ContextFinder.find(...) is incorrect :
final String jaxbContextFQCN = JAXBContext.class.getName();
...
logger.fine("Searching the system property");
// search for a system property second (javax.xml.bind.JAXBContext)
factoryClassName = AccessController.doPrivileged(new GetPropertyAction(jaxbContextFQCN));
if( factoryClassName != null )
{ return newInstance( contextPath, factoryClassName, classLoader, properties ); }
As a workaround, I use this particular value "javax.xml.bind.JAXBContext" at runtime to specify which JAXB implementation I want :
/** JAXB 2 Context Factory (System property) instead of "javax.xml.bind.context.factory" */
public static final String JAXB_CONTEXT_FACTORY = "javax.xml.bind.JAXBContext";
/** JAXB implementation 2.1.12 */
public static final String JAXB_CONTEXT_FACTORY_IMPLEMENTATION = "com.sun.xml.bind.v2.ContextFactory";
...
// Define the system property to define which JAXB implementation to use :
System.setProperty(JAXB_CONTEXT_FACTORY, JAXB_CONTEXT_FACTORY_IMPLEMENTATION);
if (logger.isLoggable(Level.INFO))
{ logger.info("JAXB implementation = " + System.getProperty(JAXB_CONTEXT_FACTORY)); }
// create a JAXBContext capable of handling classes generated into
// ivoa schema package
JAXBContext c = JAXBContext.newInstance(path);
...
Environment
x86_64 GNU/Linux
Affected Versions
[2.2.3u1]
The text was updated successfully, but these errors were encountered: