XML parser implementation [message #648757] |
Fri, 14 January 2011 07:45  |
Eclipse User |
|
|
|
I have some legacy code with dependencies to Oracles Xml parser v. 2.
I would like to deploy this as web bundle.
In order to make the code work - i need to add the jar xmlparserv2-1.0.0.jar to my bundles classpath. I have just added the jar to the lib folder in the META-INF of my bundle and added the jar to my bundles Bundle-Classpath in the MANIFEST.
This seems to work -- but now one of my other (Spring) bundles complains with
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider oracle.xml.jaxp.JXDocumentBuilderFactory not found
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Documen tBuilderFactory.java:129)
at org.springframework.beans.factory.xml.DefaultDocumentLoader. createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
at org.springframework.beans.factory.xml.DefaultDocumentLoader. loadDocument(DefaultDocumentLoader.java:70)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReade r.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
when parsing the bean definition.
The Oracle parser dependent web bundle is deployed in a PAR containing other bundles as well.
Why does adding the oracle xml parser jar to a bundles (private??) classpath affect the other bundles in my PAR?
Shouldn't they still use the standard XML parser in Java 6?
/Eva
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: XML parser implementation [message #1251439 is a reply to message #1249328] |
Thu, 20 February 2014 03:09   |
Eclipse User |
|
|
|
Hello,
I was able to resolve this issue by explicitly setting the system property before calling the sphinx dependent module in the java code and then reset it back. Something like below
//Get the properties for later resetting
String saxParserFactory = System.getProperty("javax.xml.parsers.SAXParserFactory");
String documentBuilderFactory = System.getProperty("javax.xml.parsers.DocumentBuilderFactory");
String transformerFactoryImpl = System.getProperty("javax.xml.transform.TransformerFactory");
//Override the xml properties with the apache.xerces factories
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactoryImpl");
System.setProperty("javax.xml.transform.TransformerFactory","org.apache.xalan.xsltc.trax.TransformerFactoryImpl");
//My Sphinx related code.......
//Reset the old factories back
System.setProperty("javax.xml.parsers.SAXParserFactory",saxParserFactory);
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",documentBuilderFactory);
System.setProperty("javax.xml.transform.TransformerFactory",transformerFactoryImpl);
Though my XML parsing works with this setting, using org.apache.xerces is very slow(~2 sec per xml file). any idea what could be wrong ?
Thanks,
Murthy
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05519 seconds