GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
ClassCastException at ...feed.module.georss.GeoRSSUtils.getGeoRSS  XML
Forum Index -> General
Author Message
Anonymous



Hello all,
I am using the georss module.

I was successful with using this a month ago.
Recently I revisited my code and now I am receiving the following error:

Code:
java.lang.ClassCastException: com.sun.syndication.feed.module.georss.SimpleModuleImpl
         at com.sun.syndication.feed.module.georss.GeoRSSUtils.getGeoRSS(Unknown Source)
 


I tried using the simple example on http://georss.geonames.org/

Specifically:
[/url]

Code:
 
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = input.build(new XmlReader(new URL(
          "http://www.geonames.org/recent-changes.xml")));
 
    List entries = feed.getEntries();
    for (SyndEntry entry : entries) {
         GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
         System.out.println(entry.getTitle() + " : lat="
               + geoRSSModule.getLatitude() + ",lng="
               + geoRSSModule.getLongitude() + ", desc="
               + entry.getDescription().getValue() + "; time="
               + entry.getPublishedDate());
    }
 
 


The error is pointing to this line:
GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);

Any ideas?
TIA!
Anonymous



OK I figured it out.


1 other problem.

I want to be able to input any RSS feed geo or otherwise.

What I am doing currently is the following:

Code:
       
             SyndFeed feed = input.build(new XmlReader(url));
              List entries = feed.getEntries();
                 for (Iterator it=entries.iterator();it.hasNext();) 
                 {
                     SyndEntry entry = (SyndEntry) it.next();
                     GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
                 }
                 if(geoRSSModule != null)
                 {
                  System.out.println("NOT NULL");
                  out.println(convert.getGeoJSON2(feed));
                 }
                 else
                 {
                     System.out.println("NULL");
                     out.println(convert.getJSON(feed));
                 }
         }
 


I am trying to test for null on geoRSSModule but am not successful. Is there another way to check the feed for georss?

Thanks again!
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

Hi

Would you mind sharing with us the solution to your first problem? In case other user are facing the same problem.
My guess is you were using the wrong rome release. Correct?

You can check the geoRSSModule for null to know whether a feed entry has a GeoRSS Element. It does not work for the entire feed, however, as even in a geoRSS feed not every single element necessarily has a geoRSS part. It is legal to mix geoRSS with non geoRSS. If you want to know whether all elements are geoRSS you have to loop over all entries and break the loop as soon as you find the first non-geoRSS element.

Marc

[WWW]
Anonymous



I must have corrupted the georss.jar because all I did was to download the jar with source and it started working.

Weird!


I am having trouble with this line of code:

GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);

If I pass a non geo rss feed I get a null pointer exception.

I cant figure out how to check it for null.

I tried:
converting it to a string an checking for null.
I tried:
if(geoRSSModule.equals(null))
if(geoRSSModule == null)
etc..
Still I get the null pointer.

Any ideas?
Thanks.
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

Your first code fragment should do the job, but you have to put the if within the for loop.

Regards

Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team