ClassCastException when trying to get a Service Document
--------------------------------------------------------

                 Key: ABDERA-142
                 URL: https://issues.apache.org/jira/browse/ABDERA-142
             Project: Abdera
          Issue Type: Bug
    Affects Versions: 0.2.2
         Environment: Windows XP Java 1.4.2 and Java 5.
Abdera 0.2 and 0.2.2.
            Reporter: Joseph Pecoraro


I get a ClassCastException when trying to pull a Service Document.  The 
CommonsClient correctly pulls the Service Document for the server and the 
Service Document is valid.  I will point out right now that this works just 
fine in Abdera 0.3.

Example Error:
java.lang.ClassCastException: 
org.apache.abdera.parser.stax.FOMExtensibleElement incompatible with 
org.apache.abdera.model.Service

Example Main to get the above error: [meant to be dirty but short]
public static void main(String[] args) {
                ClientResponse _response = null;
                try {
                        Abdera _abdera = new Abdera();
                        CommonsClient _client = new CommonsClient(_abdera);
                        _client.usePreemptiveAuthentication(true);
                        _client.addCredentials("https://dogear.tap.ibm.com";, 
null, null, new UsernamePasswordCredentials("username", "password"));
                        CommonsClient.registerTrustManager();
                        _response = 
_client.get("https://dogear.tap.ibm.com/api/app";);
                        if(_response != null && _response.getStatus() == 200) {
                        InputStream in = _response.getInputStream();
                        if( in != null ) {
                                Document<Service> doc = 
_abdera.getParser().parse(in);
                                Service aService = (Service)doc.getRoot();
                        }
            }  
        }
          catch(Exception e) { e.printStackTrace(); } 
        finally { _response.release(); }
}


More Information:
If I take the same code and instead grab a Feed instead of a Service Document 
using a Feed URL (such as 
https://dogear.tap.ibm.com/api/app?email=jjpecora%40us.ibm.com) and change all 
occurrences of "Service" to "Feed" it runs without any issues and the Feed is 
loaded properly  The same can be done with an Entry just like a Feed.

If I take the same code and instead use Abdera 0.3 (and replace all instances 
of "CommonsClient" with "AbderaClient") it runs without any issues.

I have tried multiple Service Documents and the error persists.  I manually 
read and scanned the InputStream for abnormalities that I thought might have 
affected the Parser and it looks like a perfectly valid Atom Service Document.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to