Menu

#619 ClassCastException on Ajax4jsf response

closed
None
5
2012-10-21
2008-05-20
No

I attached a patch of XmlPageTest that reproduces this issue.

When Ajax4jsf returns its XML Ajax response, you get:

java.lang.ClassCastException: com.gargoylesoftware.htmlunit.xml.XmlPage
at com.gargoylesoftware.htmlunit.html.HtmlElement.getPage(HtmlElement.java:1425)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:195)
at com.gargoylesoftware.htmlunit.html.DomNode.appendChild(DomNode.java:857)
at com.gargoylesoftware.htmlunit.xml.XmlUtil.copy(XmlUtil.java:203)
at com.gargoylesoftware.htmlunit.xml.XmlUtil.copy(XmlUtil.java:204)
at com.gargoylesoftware.htmlunit.xml.XmlUtil.appendChild(XmlUtil.java:138)
at com.gargoylesoftware.htmlunit.xml.XmlPage.<init>(XmlPage.java:117)
at com.gargoylesoftware.htmlunit.xml.XmlPage.<init>(XmlPage.java:75)
at com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest.jsxGet_responseXML(XMLHttpRequest.java:219)

Discussion

  • Stan Silvert

    Stan Silvert - 2008-05-20

    Test to reproduce ClassCastException

     
  • Daniel Gredler

    Daniel Gredler - 2008-05-21

    Logged In: YES
    user_id=1109422
    Originator: NO

    It seems to me that this is the tip of the iceberg. Up to now, all HtmlElements have been happy in the knowledge that they can assume that they are inside an HtmlPage (see the overridden HtmlElement#getPage()). If I delete the overridden getPage() method (which appears to be necessary for Marc's previous fix to be complete) I get 66 compile errors -- places where the code expects an HtmlPage. If I change the overridden method signature to return an SgmlPage, I still get 43 compile errors.

    @Marc: Do we really need to create HtmlElements inside an XmlPage? Can we not just make an HtmlPage? Are there any other options?

     
  • Marc Guillemot

    Marc Guillemot - 2008-05-21

    Logged In: YES
    user_id=402164
    Originator: NO

    Now fixed in SVN.

    @Daniel:
    we have to use an XmlPage as html nodes may be contained withing "pure" xml nodes. My fix for this issue is rather as hack (instanceof at 2 places) and we surely needs some internal refactoring to handle this cleanly. Unit tests are in place.

     

Log in to post a comment.