How do I read RSS from Google App Engine? Getting JDOM could not create a SAX parser

。_饼干妹妹 提交于 2019-12-09 07:14:16

问题


I am trying to write a simple Google App Engine website that reads an external RSS feed. I am using ROME with JDOM, however I am getting the impression that ROME is not compatible with Google App Engine and how you may fetch data.

ROME uses the build method of the SyndFeedInput class, but I cannot find any way to how to connect this with Google App Engine and URL Fetch.

My sample code is:

URL url = new URL(rss_url);
Reader r = new InputStreamReader(url.openStream());
SyndFeed feed = new SyndFeedInput().build(r);

But on my third row I get a

java.lang.IllegalStateException: JDOM could not create a SAX parser

It works if I run the code in an own stand alone application, but when I trigger the code via Google App Engine locally, I get the exception.

What I am doing wrong and what alternatives can I try to read an external RSS?


回答1:


Looks like ROME isn't supported on GAE:

http://old.nabble.com/ROME-and-AppEngine-td23290454.html

http://code.google.com/p/googleappengine/issues/detail?id=1367

It seems that the workaround is to include a copy of the Xerces JAR in your application, so that JDOM doesn't try to load it from GAE itself.




回答2:


Worked for me with: GAE 1.4.0 rome 1.0 jdom 1.1.1 xercesImpl-2.11.0.jar xml-apis.jar




回答3:


There is a work around for this issue with JDOM, which then solves the problem for ROME

Place xercesImpl-x.x.x.jar in war/WEB-INF/lib

See http://code.google.com/p/googleappengine/issues/detail?id=1367 Many people copy more than xercesImpl or libraries that contain xerces (e.g. some distributions of xalan), however xercesImpl is all you need.

It is still a work around as it appears JDOM isn't using JAXP correctly to load GAE's SAX parser.

Worked for me with: GAE 1.3.7 rome 1.0 jdom 1.1.1 xercesImpl-2.6.1.jar



来源:https://stackoverflow.com/questions/2302652/how-do-i-read-rss-from-google-app-engine-getting-jdom-could-not-create-a-sax-pa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!