Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

ClassCastException

Help
2009-06-19
2013-06-06
  • Mike Miller
    Mike Miller
    2009-06-19

    Hi,

    Just starting to use RESTEasy and this is as close as I've found for a forum.  I took the SimpleExample and tried to duplicate it in Eclipse with a DynamicWebProject.   When I tried to do the post to create a new object, I get the following:

    .ws.rs.WebApplicationException: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredTextImpl cannot be cast to org.w3c.dom.Element
        at org.rest.services.ProcessResource.readProcess(ProcessResource.java:111)
        at org.rest.services.ProcessResource.createProcess(ProcessResource.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    ...

    From the sample code - the exception happens here:

    --- inside readCustomer
    NodeList nodes = root.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
       Element element = (Element) nodes.item(i);

    nodes.item(i) returns a DeferredTextImpl which can't be casted to an Element.

    Any idea what I am doing wrong?

     
    • Mike Miller
      Mike Miller
      2009-06-22

      Never mind - the problem was whitespace in the xml document - so the Node I was getting back was not an Element but a Text element.