[SOLVED] Feed Binding

I think since snapshot #1522 the Feed Binding isn’t working properly anymore.
The thing status remains at:

Status: OFFLINE - CONFIGURATION_ERROR Invalid XML: Error on line 1: DOCTYPE ist nicht zulässig, wenn das Feature "http://apache.org/xml/features/disallow-doctype-decl" auf "true" gesetzt ist.

Any ideas how to fix it?

Warning in the logs:

2019-02-21 21:26:48.054 [WARN ] [ng.feed.internal.handler.FeedHandler] - Feed content is not valid: http://www.lebensmittelwarnung.de/bvl-lmw-de/app/feed/hessen.rss 
com.rometools.rome.io.ParsingFeedException: Invalid XML: Error on line 1: DOCTYPE ist nicht zulässig, wenn das Feature "http://apache.org/xml/features/disallow-doctype-decl" auf "true" gesetzt ist.
	at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:236) ~[?:?]
	at com.rometools.rome.io.SyndFeedInput.build(SyndFeedInput.java:150) ~[?:?]
	at org.openhab.binding.feed.internal.handler.FeedHandler.fetchFeedData(FeedHandler.java:228) ~[?:?]
	at org.openhab.binding.feed.internal.handler.FeedHandler.refreshFeedState(FeedHandler.java:111) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.jdom2.input.JDOMParseException: Error on line 1: DOCTYPE ist nicht zulässig, wenn das Feature "http://apache.org/xml/features/disallow-doctype-decl" auf "true" gesetzt ist.
	at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:232) ~[?:?]
	at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:303) ~[?:?]
	at org.jdom2.input.SAXBuilder.build(SAXBuilder.java:1196) ~[?:?]
	at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:233) ~[?:?]
	... 10 more
Caused by: org.xml.sax.SAXParseException: DOCTYPE ist nicht zulässig, wenn das Feature "http://apache.org/xml/features/disallow-doctype-decl" auf "true" gesetzt ist.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[?:?]
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) ~[?:?]
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) ~[?:?]
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) ~[?:?]
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472) ~[?:?]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:914) ~[?:?]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602) ~[?:?]
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) ~[?:?]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505) ~[?:?]
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841) ~[?:?]
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770) ~[?:?]
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[?:?]
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) ~[?:?]
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643) ~[?:?]
	at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:217) ~[?:?]
	at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:303) ~[?:?]
	at org.jdom2.input.SAXBuilder.build(SAXBuilder.java:1196) ~[?:?]
	at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:233) ~[?:?]
	... 10 more

The guys from lmw recently changed the RSS. They build up many bugs. And this is obvious another one from lmw. They didn’t configured the rss right.

The best is to tell them, that they did something wrong. In the meantime you can maybe use my “raw” code to get the new rss posts.

rss.items
String RSSLmwCache

rss.rules

rule "Lebensmittelwarnungen"
when
	Time cron "0 15 0/2 ? * *"
then
	val String BASE = "/*[name()='rss']/*[name()='channel']/*[name()='item']"
	val String oldCache = RSSLmwCache.state.toString
	var String newCache = ""
	
	val String rawString = sendHttpGetRequest( "https://www.lebensmittelwarnung.de/bvl-lmw-de/opensaga/feed/alle/baden_wuerttemberg.rss" )
	logInfo( "rss", "Hole articleCounter für Lebensmittelwarnungen" )
	val String articleCounter = transform( "XPATH", "count(" + BASE + ")", rawString )
	logInfo( "rss", "articleCounter as String = " + articleCounter )
	val int count = Integer::parseInt( articleCounter )
	var int i = 1

	while ( i <= count ) {
		logInfo( "rss", "Schleifendurchlauf " + i )
		val String articleId = transform( "XPATH", BASE + "[" + i + "]/*[name()='guid']", rawString )
		newCache = newCache + "|" + articleId

		if( !oldCache.contains( articleId ) ) {
			logInfo( "rss", "oldCache contained articleId NOT" )
			// Neuer Artikel
			val String url = transform( "XPATH", "string(" + BASE + "[" + i + "]/*[name()='link'])", rawString )
			val String title = transform( "XPATH", "string(" + BASE + "[" + i + "]/*[name()='title'])", rawString )
			val String message = title + "\n" + url
			logInfo( "rss", "message = " + message )
			sendTelegram("RSSBot", message)
		}
		i = i + 1
	}
	RSSLmwCache.postUpdate( newCache )
end
1 Like

Thanks for your reply and your rule. I also will definitely let them know.

1 Like

Ok, it was even easier. It was enough to renew the url. The new one https://www.lebensmittelwarnung.de/bvl-lmw-de/opensaga/feed/alle/hessen.rss works with the feed binding (my thing was configured with http://www.lebensmittelwarnung.de/bvl-lmw-de/app/feed/hessen.rss).
Maybe it’s also an option for you.

Hm. Ok, sorry. I only looked at the later part of the URI. But to save my bashing of lmw: if they would redirect is from http to https this never happens. :smile:

The feed binding doesn’t work for me, because (as far as I know) it only returns the number of new articles.

No worries, without your answer, I wouldn’t have seen it.
Btw: you get more informations than only the number of new articles (have a look at the available channels in PaperUI). But you have to process the given information also (and I suppose, your way is cleaner).
Anyway, that’s the way I do it:

rule "Lebensmittelwarnungen Hessen"
when
    Item Feed_LatestTitle_HES changed
then
	val HEScorrected = Feed_LatestDescription_HES.state.toString.replaceAll("\\t|\\r|\\n", "").replaceAll("<[^>]*>", " ").replace("&#223;", "ß").replace("&#38;", "&").replace("&#228;", "ä").replace("&#252;", "ü").replace("&#220;", "Ü").replace("&#246;", "ö").replace("&#214;", "Ö").replace("&#233;", "é").replace("&#160;", " ").replace("&#8222;", "„").replace("&#8220;", "“").replace("&#34;", "\"").replace("Hersteller (Inverkehrbringer): ", "").replaceAll("[ ]{2,}", "\n")
	val HESlink = Feed_LatestDescription_HES.state.toString.split("\"").get(1)
	try {
		sendTelegramPhoto("bot2", HESlink.toString, null)
	} finally {
		sendTelegram("bot2", Feed_Description_HES.state.toString + "\n" + Feed_LatestTitle_HES.state.toString + "\n" + HEScorrected.toString)
	}
 end

Result:
Picture (if available)

In Hessen wird vor folgenden Produkten gewarnt.
Alnatura Kinder-Bircher-Müsli (ab 1 Jahr) und Alnatura Müslikekse (ab 15. Monat)

Produktbezeichnung: Alnatura Kinder-Bircher-Müsli (ab 1 Jahr)undAlnatura Müslikekse (ab 15. Monat)
Typ: Lebensmittel
Alnatura Produktions- und Handels GmbHMahatma-Gandhi-Straße 764295 Darmstadt
Grund der Warnung: In den genannten Produkten können sich Teile von Apfelstielen befinden.
Betroffene Länder: Baden-Württemberg, Bayern, Berlin, Brandenburg, Bremen, Hamburg, Hessen, Niedersachsen, Nordrhein-Westfalen, Rheinland-Pfalz, Saarland, Sachsen, Schleswig-Holstein, Thüringen

Thanks again, for your help!

1 Like