Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect System property to define the provider factory class #816

Closed
Tomas-Kraus opened this issue Mar 8, 2011 · 6 comments
Closed

Incorrect System property to define the provider factory class #816

Tomas-Kraus opened this issue Mar 8, 2011 · 6 comments

Comments

@Tomas-Kraus
Copy link
Member

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]

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Reported by bourgeslaurent

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Was assigned to snajper

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
snajper said:
Fixed, first the documented property is being looked at, the current way is kept still for compatibility reasons.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Marked as fixed on Tuesday, April 5th 2011, 8:46:30 pm

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAXB-816

@Tomas-Kraus
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants