Martin W. created JENA-328:
------------------------------
Summary: NodeValue makes assumptions about ClassLoader --- "nasty
problem is OSGi environments"
Key: JENA-328
URL: https://issues.apache.org/jira/browse/JENA-328
Project: Apache Jena
Issue Type: Bug
Components: ARQ, Jena
Affects Versions: Jena 2.7.3
Environment: OSGi: Virgo Server for Apache Tomcat
Reporter: Martin W.
Priority: Minor
com.hp.hpl.jena.sparql.expr.NodeValue.java: in lines 175ff:
A new instance of a DatatypeFactory is created with .newInstance() --- there
assumptions are made about the classloader. Such things make it difficult to
use Jena in an OSGi-Environment like Virgo.
Here's my fix: (get the correct classloader first and call newInstance with
that classloader as parameter)
{
try {
ClassLoader cl =
com.hp.hpl.jena.sparql.expr.NodeValue.class.getClassLoader();
xmlDatatypeFactory =
DatatypeFactory.newInstance(DatatypeFactory.DATATYPEFACTORY_IMPLEMENTATION_CLASS,
cl) ; }
catch (DatatypeConfigurationException ex)
{ throw new ARQInternalErrorException("Can't create a javax.xml
DatatypeFactory", ex) ; }
}
This fix did it for me. However, the JavaDoc for
DatatypeFactory.DATATYPEFACTORY_IMPLEMENTATION_CLASS states "Users should not
refer to this field; it is intended only to document a factory implementation
detail. "
NOTE: furthermore I added the original exception ex to:
throw new ARQInternalErrorException("Can't create a javax.xml DatatypeFactory",
ex)
For more information on OSGi and classloaders see also
http://stackoverflow.com/questions/1043109/why-cant-jaxb-find-my-jaxb-index-when-running-inside-apache-felix
Hanno Fietz wrote there "... quite nasty problem in OSGi environments when
you're using libraries that aren't designed for OSGi and make assumptions about
the classloader they get."
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira