How do I read RSS from Google App Engine? Getting

2020-06-06 05:17发布

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?

3条回答
叛逆
2楼-- · 2020-06-06 05:47

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

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-06-06 05:50

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

查看更多
萌系小妹纸
4楼-- · 2020-06-06 05:53

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.

查看更多
登录 后发表回答