Heim  >  Artikel  >  Backend-Entwicklung  >  Zusammenfassung der Probleme beim Parsen von RSS

Zusammenfassung der Probleme beim Parsen von RSS

Y2J
Y2JOriginal
2017-04-24 16:35:552497Durchsuche

try{ 
   org.dom4j.io.SAXReader saxReader = new org.dom4j.io.SAXReader();
   org.dom4j.Document document = saxReader.read(rssUrl);
   org.dom4j.Element channel = (org.dom4j.Element) document.getRootElement().element("channel");
     int index =0;
           for (java.util.Iterator i = channel.elementIterator("item"); i.hasNext();){ 
            if(index+1>rssTable.Rows.length){
             break;
            } 
             org.dom4j.Element element = (org.dom4j.Element) i.next();
                String title = element.elementText("title");
                String link = element.elementText("link");
                String pubDate = element.elementText("pubDate");
                String source = element.elementText("source");  
                ci.adp.DataRow rssRow = rssTable.getDataRowByIndex(index);
              
                rssRow.setValue("TITLE", title);
                rssRow.setValue("LINK", link);
                rssRow.setValue("PUBDATE", pubDate);
                rssRow.setValue("SOURCE", source); 
                /*
                System.out.println("title标题: " + title);
                System.out.println("link链接: " + link);
                System.out.println("pubDate发布时间: " +pubDate); 
                System.out.println("source来源: " + source);
                */
                index++;  
           }
  }catch (Exception e) { 
   e.printStackTrace();
  }

Nachdem ich den ganzen Morgen gekämpft hatte, habe ich es endlich auf eine andere Art und Weise geschafft.

Die obige dom4j-Methode funktioniert gut in meiner lokalen Umgebung (Windows+weblogic10+jdk1.6),
lege sie auf den Server (linux5.4 x64+weblogic10 +jdk1. 6) wird dieser Fehler immer gemeldet:

[oracle@ablw010215 bin]$ Warning: Caught exception attempting to use SAX to load a SAX XMLReader
Warning: Exception was: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration
Warning: I will print the stack trace then carry on using the default SAX parser
java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration
        at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:199)
        at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:150)
        at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)
        at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
        at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
        at org.dom4j.io.SAXReader.read(SAXReader.java:435)
        at org.dom4j.io.SAXReader.read(SAXReader.java:321)
        at jsp_servlet._ajax._comm._bbs.__iframearticlecontent._jspService(__iframearticlecontent.java:100)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at ci.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:107)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
org.dom4j.DocumentException: SAX2 driver class weblogic.xml.jaxp.RegistryXMLReader does not implement XMLReader Nested exception: SAX2 driver class weblogic.xml.jaxp.RegistryXMLReader does not implement XMLReader
        at org.dom4j.io.SAXReader.read(SAXReader.java:484)
        at org.dom4j.io.SAXReader.read(SAXReader.java:321)
        at jsp_servlet._ajax._comm._bbs.__iframearticlecontent._jspService(__iframearticlecontent.java:99)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at ci.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:107)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Nested exception: 
java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration
        at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:98)
        at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
        at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
        at org.dom4j.io.SAXReader.read(SAXReader.java:435)
        at org.dom4j.io.SAXReader.read(SAXReader.java:321)
        at jsp_servlet._ajax._comm._bbs.__iframearticlecontent._jspService(__iframearticlecontent.java:100)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at ci.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:107)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Nested exception: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration
        at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:98)
        at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
        at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
        at org.dom4j.io.SAXReader.read(SAXReader.java:435)
        at org.dom4j.io.SAXReader.read(SAXReader.java:321)
        at jsp_servlet._ajax._comm._bbs.__iframearticlecontent._jspService(__iframearticlecontent.java:100)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at ci.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:107)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

5ec35a6e65935d15cb9c490e1c779837 Socket, da am 10.16.99.18:53.874 während der konfigurierten Leerlaufzeit von 5 Sekunden keine Daten gelesen wurden>
5ec35a6e65935d15cb9c490e1c779837 b382046ee41c398bcec9921d8832c4ff BEA-000449> ec2be0d6e6ff54fa0fb0cbb80a0c66f4

Konfigurationsdateien hinzufügen, lib hinzufügen Pakete usw. an Weblogic

Das obige ist der detaillierte Inhalt vonZusammenfassung der Probleme beim Parsen von RSS. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn