Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » XML parser implementation
XML parser implementation [message #648757] Fri, 14 January 2011 12:45 Go to next message
Eva Troels is currently offline Eva TroelsFriend
Messages: 17
Registered: December 2010
Junior Member
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 #648786 is a reply to message #648757] Fri, 14 January 2011 14:08 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Does the parser dependent web bundle accidentally export any XML parser packages?
Re: XML parser implementation [message #648792 is a reply to message #648786] Fri, 14 January 2011 14:21 Go to previous messageGo to next message
Eva Troels is currently offline Eva TroelsFriend
Messages: 17
Registered: December 2010
Junior Member
No, the only Export-Packages are internal business logic classes.

The oracle parser jar contains classes in the packages javax.xml.parsers, javax.xml.transform, javax.xml.transform.dom, javax.transform.sax, javax.transform.stream.

But why do the classes in these packages show up on the other bundles classpath??

/Eva
Re: XML parser implementation [message #648798 is a reply to message #648792] Fri, 14 January 2011 14:30 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
I guess it's due to the peculiar way in which document builder factories are located, which is presumably not OSGi friendly. I'd be very surprised if the Oracle classes are actually loadable from the other bundles.

Not sure how to proceed on this one. Have you tried deploying the bundles outside a PAR for comparison?
Re: XML parser implementation [message #648805 is a reply to message #648798] Fri, 14 January 2011 15:19 Go to previous messageGo to next message
Eva Troels is currently offline Eva TroelsFriend
Messages: 17
Registered: December 2010
Junior Member
Haven't tried that.
Setting the parameters

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apach e.xerces.internal.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.transform.TransformerFactory=com.sun.org.apache. xalan.internal.xsltc.trax.TransformerFactoryImpl -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerc es.internal.jaxp.SAXParserFactoryImpl

in the virgo servers launch configuration got me past the error, though.

/Eva
Re: XML parser implementation [message #648809 is a reply to message #648805] Fri, 14 January 2011 15:35 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
I suppose desperate times call for desperate measures.

Glad you are making progress now. Smile
Re: XML parser implementation [message #648965 is a reply to message #648809] Sun, 16 January 2011 20:11 Go to previous messageGo to next message
Eva Troels is currently offline Eva TroelsFriend
Messages: 17
Registered: December 2010
Junior Member
Right you are!

You are probably right that the Oracle code is osgi-hostile - using System.setProperty or something like that.

Oh well Smile

/Eva
Re: XML parser implementation [message #1122793 is a reply to message #648757] Tue, 01 October 2013 23:36 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
Registered: January 2012
Senior Member
Sorry to brings to this old thread alive again, but I've got this problem here to.
I have a bundle that embeds Eclipse Birt Runtime using Bundle ClassPath, and after do that, some other bundles have throw this error by simple loading their spring contexts.

Can a bundle classpath inner dependency, afect how another bundles context is loaded? This can be some bug? I can post a test case to replicate this problem if needed.

Re: XML parser implementation [message #1123071 is a reply to message #1122793] Wed, 02 October 2013 06:57 Go to previous messageGo to next message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior Member
It would be great if you can provide a "small" test case to reproduce this problem. Then it will be much easier for interested people digging into this problem if they can spare some time.

[Updated on: Wed, 02 October 2013 10:37]

Report message to a moderator

Re: XML parser implementation [message #1123312 is a reply to message #1123071] Wed, 02 October 2013 12:32 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
Registered: January 2012
Senior Member
Sure! I will do that this afternoon! Thanks!
Re: XML parser implementation [message #1123736 is a reply to message #1123071] Wed, 02 October 2013 21:49 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo FrazãoFriend
Messages: 123
Registered: January 2012
Senior Member
I've tried to create a test case, but I can't replicate the problem only configuring the Bundle-Classpath with the xml parser..

I guess that Birt Report Engine sets a new parser when it is configured. Post a test project case, with all the Birt runtime will be a bad idea (about 50MB). I will post more details!
Re: XML parser implementation [message #1249328 is a reply to message #1123736] Tue, 18 February 2014 06:13 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
Hello,

I am sorry to reopen the thread again !.

I have a similar case in my Virgo setup where I have conflicts with the org.apache.xerces.jaxp.SAXParserFactoryImpl, and com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl. I have my JMX_OPTS in dmk.bat for my xml needs as below

Quote:
set JMX_OPTS=%JMX_OPTS% -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
set JMX_OPTS=%JMX_OPTS% -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
set JMX_OPTS=%JMX_OPTS% -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl


While I want to use the com.sun.*.SAXParserFactory for my xml loading needs, I depend on a library(eclipse.sphinx.emf) which depends on org.apache.xerces.*.SAXParserFactoryImpl. So while using the library I get the below error.

Quote:
[Request processing failed; nested exception is java.lang.ClassCastException: org.eclipse.sphinx.emf.resource.ExtendedErrorHandlerWrapper cannot be cast to com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler] with root cause java.lang.ClassCastException: org.eclipse.sphinx.emf.resource.ExtendedErrorHandlerWrapper cannot be cast to com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.setProperty(XMLErrorReporter.java:589)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.setProperty(XML11Configuration.java:965)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setProperty(AbstractSAXParser.java:1946)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.setProperty(SAXParserImpl.java:518)
at org.eclipse.sphinx.emf.resource.ExtendedXMLLoadImpl.load(ExtendedXMLLoadImpl.java:180)


Is there a way to override the JMX_OPTS for a special cases ?

Thanks,
Murthy
Re: XML parser implementation [message #1251439 is a reply to message #1249328] Thu, 20 February 2014 08:09 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
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
Re: XML parser implementation [message #1256278 is a reply to message #1251439] Tue, 25 February 2014 09:14 Go to previous messageGo to next message
Florian Waibel is currently offline Florian WaibelFriend
Messages: 166
Registered: June 2010
Senior Member
Hi Murthy,

did you find some more time to investigate this? (e.g. with a profiling tool as mentioned here).

Regards,
florian
Re: XML parser implementation [message #1262198 is a reply to message #1256278] Mon, 03 March 2014 11:11 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
Hello Florian,

Yes,we've tried the yourkit profiler. We are still stuck with the sphinx library as it depends on "org.apache.xerces". Somehow our xml parsing is 5 times faster when I use com.sun.org.apache as compared to parsing using org.apache.xalan. I have posted my query question in Sphinx forum, but have not got any response yet.

Also I sometimes face some problems while starting up the Virgo server due to the sphinx library. Apparently when virgo tries to resolve the dependencies of org.eclipse.sphinx.platform, sometimes it enters into a race condition where the server startup just hangs. Restart is then the only way out. Any idea what could be wrong ? Could these issues related ?

Thanks,
Murthy
Re: XML parser implementation [message #1853124 is a reply to message #1251439] Sun, 19 June 2022 14:14 Go to previous message
KEERTHI BILWARAJ is currently offline KEERTHI BILWARAJFriend
Messages: 2
Registered: December 2017
Junior Member
It worked for me @Murthy Bhat. Thank you!

[Updated on: Sun, 19 June 2022 14:16]

Report message to a moderator

Previous Topic:Virgo Future
Next Topic:AspectJ logs not printing issue with Open JDK 17
Goto Forum:
  


Current Time: Tue Dec 10 17:41:02 GMT 2024

Powered by FUDForum. Page generated in 0.04865 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top