Friday, February 11, 2011

org.apache.abdera.parser.ParseException: com.ctc.wstx.exc.WstxException: Illegal null byte in input stream

Got this at work a couple of weeks ago, just got around putting it out here.
We use abdera1.0 to parse XML from a restful call:

 org.apache.abdera.parser.stax.FOMParser feedParser = new org.apache.abdera.parser.stax.FOMParser();
 InputStream in =new URL("http://randomdonkeys.com/give_me_my_donkey.atom").openStream();
 Document<Feed> feedDoc = feedParser.parse(in);

The .parse call threw the WstxException. After digging around discovered that the abdera1.0 jar has issues with parsing ChunckedInputStream. I was able to get around it by wrapping the InputStream in InputStreamReader:

Document<Feed> feedDoc = feedParser.parse(new InputStreamReader(in));

Hope this helps someone at some point.

4 comments:

  1. Replies
    1. Glad the post was useful! Thanks for leaving a note :) Cheers!

      Delete
  2. Thanks a lot!!!!!! It worked

    ReplyDelete