如何从Google App Engine读取RSS?获取JDOM无法创建SAX解析器 [英] How do I read RSS from Google App Engine? Getting JDOM could not create a SAX parser

查看:127
本文介绍了如何从Google App Engine读取RSS?获取JDOM无法创建SAX解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简单的Google App Engine网站来读取外部RSS源。我正在使用ROMOM与JDOM,但是我得到了ROME与Google App Engine不兼容以及如何获取数据的印象。



ROME使用 SyndFeedInput 类的构建方法,但我找不到任何方式来连接它与Google App Engine和URL Fetch。



<我的示例代码是:

  URL url = new URL(rss_url); 
读者r =新的InputStreamReader(url.openStream());
SyndFeed feed = new SyndFeedInput()。build(r);

但是在第三行我得到了一个

  java.lang.IllegalStateException:JDOM无法创建SAX解析器

如果我在自己的独立应用程序中运行代码,但它在我本地通过Google App Engine触发代码时出现异常,那么它就可以工作。



我做错了,我可以尝试读取外部RSS的其他选择吗?

解决方案

看起来像GAE不支持ROME :



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



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



看来解决方法是在您的应用程序中包含Xerces JAR的副本,以便JDOM不会尝试从GAE本身加载它。


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?

解决方案

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.

这篇关于如何从Google App Engine读取RSS?获取JDOM无法创建SAX解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆