1

i am trying to create rss feeds app that parses all the websites supporting feed. i used Jsoup for this purpose. and parsed for different type of rss in this way

org.jsoup.select.Elements links = doc.select("link[type=application/rss+xml]");  
org.jsoup.select.Elements links = doc.select("link[type=application/atom+xml]");

it parses various websites like engadget.com, ndtv.com etc but when i tried to pase websites like stackoverflow.com or 1up.com i got the following error.

thread exiting with uncaught exception (group=0x40efe378)

and

Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=/rss

searching for error #1 didnt yield even 1 results. searching for eroror #2 had many. all stated to use http:// before any websites url like

http://1up.com

but then too the error persists. and i had already implemented this before since all other websites rss are parsed. this is my logcat for 1up.com rss feed.

D/URL Length(4097): 14
D/url name(4097): http://1up.com
D/No of RSS links found(4097):  1
W/dalvikvm(4097): threadid=12: thread exiting with uncaught exception (group=0x40efe378)
E/AndroidRuntime(4097): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(4097): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(4097):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
E/AndroidRuntime(4097):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime(4097):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime(4097):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime(4097):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime(4097):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
E/AndroidRuntime(4097):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/AndroidRuntime(4097):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/AndroidRuntime(4097):     at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime(4097): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=/rss
E/AndroidRuntime(4097):     at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591)
E/AndroidRuntime(4097):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293)
E/AndroidRuntime(4097):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
E/AndroidRuntime(4097):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
E/AndroidRuntime(4097):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
E/AndroidRuntime(4097):     at com.maulik.rss.RssParser.getXmlFromUrl(RssParser.java:214)
E/AndroidRuntime(4097):     at com.maulik.rss.RssParser.getRSSFeed(RssParser.java:69)
E/AndroidRuntime(4097):     at com.maulik.rss.RSS_AddNewSiteActivity$loadRSSFeed.doInBackground(RSS_AddNewSiteActivity.java:97)
E/AndroidRuntime(4097):     at com.maulik.rss.RSS_AddNewSiteActivity$loadRSSFeed.doInBackground(RSS_AddNewSiteActivity.java:1)
E/AndroidRuntime(4097):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
E/AndroidRuntime(4097):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime(4097):     ... 5 more
8
  • can anyone tell me how to view rss file for 1up.com when i click on this link feeds.feedburner.com/1up/ALLPS3/content the contents are shown not in xml. if theres anyway i can have a look in xml then i can even try to figure out the problem Commented Sep 15, 2013 at 16:45
  • i think i found the problem, sites engadget.com uses <channel> and i parsed using this itself. but websites like stackoverflow.com feeds have <entry>. now can anyone tell me how can i stop parsing feeds with <entry>tag? Commented Sep 15, 2013 at 17:41
  • When do you get the errors? When you try to get the links to feeds or when you try to parse the raw feeds? Commented Sep 15, 2013 at 18:28
  • @z2s8 when i try to get the rss url, i used log message to display the links found or not. so for 1up.com log message was 'no of rss link found:1' and afterwards i got the error. but for stackoverflow.com rss, it stated that no rss link found and the error showed up. so its the parsing thats causing the error. but the rss of engadget and 1up.com is the same structure engadget.com/rss.xml 1up.com/rss then too engadget's rss are properly parsed Commented Sep 15, 2013 at 18:45
  • Seems to me that IllegalStateException: Target host must not be null, or set in parameters. indicates that the problem is caused by invalid (or null) RSS address. From 1up.com : <link rel="alternate" type="application/rss+xml" title="RSS" href="/rss?x=1" /> and from your logcat output seems the request goes to wrong address: rss?x=1 (or same w/o http) so instead of the relative link 1up.com/rss, it handles the link as an absolute one. You could detect relative links and convert them to absolute ones before parsing feeds. Commented Sep 16, 2013 at 19:26

1 Answer 1

1

IllegalStateException: Target host must not be null, or set in parameters. indicates that the problem is caused by invalid (or null) RSS address.

From http://1up.com: <link rel="alternate" type="application/rss+xml" title="RSS" href="/rss?x=1" /> and from your logcat output seems the request goes to wrong address: http:// rss?x=1 (or same w/o http) so instead of the relative link 1up.com/rss, it handles the link as an absolute one.
You could detect relative links and convert them to absolute ones before parsing feeds.

While some sites use the RSS standard, some others use the Atom standard. RSS and Atom feeds' tags are different.
You may need to create different parsing algorithms for each feed type.

Sign up to request clarification or add additional context in comments.

1 Comment

hi thanks for the help, i have already created parsers for both type of rss standards. its all working fine now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.