1

尝试解析 atom 提要时收到以下错误。org.apache.abdera.parser.ParseException: java.lang.ArrayIndexOutOfBoundsException at org.apache.abdera.parser.stax.FOMParser.parse(FOMParser.java:128) at org.apache.abdera.util.AbstractParser.parse(AbstractParser .java:73) 在 testfeedreader.TestFeedReader.main(TestFeedReader.java:44) 引起:java.lang.ArrayIndexOutOfBoundsException ....

这是我给读者的代码。我硬编码了用于测试的 url:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testfeedreader;

import java.io.IOException;
import java.net.URL;
import java.util.List;

import org.apache.abdera.Abdera;
import org.apache.abdera.model.Document;
import org.apache.abdera.model.Entry;
import org.apache.abdera.model.Feed;
import org.apache.abdera.model.Category;
import org.apache.abdera.model.Link;
import org.apache.abdera.parser.ParseException;
import org.apache.abdera.parser.Parser;

/**
 *
 * @author srieger
 */
public class TestFeedReader {

    private static Abdera abdera = null;

    /**
     *
     * @return
     */
    public static synchronized Abdera getInstance() {
        if (abdera == null) {
            abdera = new Abdera();
        }
        return abdera;
    }

    public static void main(String[] args) {
        Parser parser = getInstance().getParser();

        try {
            URL url = new URL("http://connect.lmsnet.com/files/basic/anonymous/api/documents/feed");
            Document<Feed> doc = parser.parse(url.openStream(), url.toString());
            Feed feed = doc.getRoot();
            // Get the feed title
            System.out.println("Feed Title: " + feed.getTitle());

            // Get the entry items...
            for (Entry entry : feed.getEntries()) {
                System.out.println("Title: " + entry.getTitle());
                System.out.println("Unique Identifier: " + entry.getId().toString());
                System.out.println("Updated Date: " + entry.getUpdated().toString());
                System.out.println("Published Date: " + entry.getPublished());
                System.out.println("Content: " + entry.getContent());

                // Get the links
                for (Link link : (List<Link>) entry.getLinks()) {
                    System.out.println("Link: " + link.getHref());
                }               

                // Get the categories
                for (Category category : (List<Category>) entry.getCategories()) {
                    System.out.println("Category: " + category.getTerm());
                }
            }
        } catch( IOException | ParseException e )
        {
            e.printStackTrace();
        }
    }
}
4

2 回答 2

1

根据讨论,答案是:代码获取日志页面作为响应,因此发生解析错误。

可能性:

  1. SSO 配置 - 研究 SBT SDK 文档并使用 SSO 进行身份验证。

  2. 将您的代码移动到客户端 - 因此,改为在后台在 SSJS/Java 中处理它,使用一些小部件和 JS 解析向用户显示所需的信息。这样,呼叫将通过浏览器中的用户身份进行身份验证。

于 2015-02-24T18:22:18.733 回答
0

apache abdera 使用org.apache.axiomlib,因此将其用作 pom 文件中的依赖项。你可以使用另一个 catch 块来检查它,它会抛出NoClassDefFoundError。这个答案可以帮助正在看这个的人。

于 2019-05-10T02:18:23.223 回答