Error appears in some pages with ajax. I believe that processed xml is an ajax response.
In class XmlPage, row 145 is transmitted local name of attribute (i.e. "space" instead of "xml:space") and this leads to errors in DomNamespaceNode constructor.
There are 2 solutions, to pass fully qualified name (i.e. "xml:space") or to make accept DomNamespaceNode accept local qualified names.
Now I don't know what solution is the correct one, so I tried both.
For first solution modifications are
class: XmlPage
row 145
+ new XmlAttr(this, attribute.getNamespaceURI(), attribute.getNodeName(), attribute.getNodeValue());
- new XmlAttr(this, attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getNodeValue());
row 148
+ final XmlElement element = new XmlElement(node.getNamespaceURI(), node.getNodeName(), this, attributes);
- final XmlElement element = new XmlElement(node.getNamespaceURI(), node.getLocalName(), this, attributes);
For second solution modifications are
class: DomNamespaceNode
row 72++ added:
if (colonPosition >= 0) {
localName_ = qualifiedName_.substring(colonPosition + 1);
prefix_ = qualifiedName_.substring(0, colonPosition);
} else {
localName_ = qualifiedName_;
prefix_ = null;
}
instead of:
localName_ = qualifiedName_.substring(colonPosition + 1);
prefix_ = qualifiedName_.substring(0, colonPosition);
Now when I try to run my test second time I have another error (for both solutions):
va.lang.ClassCastException: com.gargoylesoftware.htmlunit.xml.XmlPage cannot be cast to com.gargoylesoftware.htmlunit.html.HtmlPage
at com.gargoylesoftware.htmlunit.html.DomNode.getPage(DomNode.java:272)
at com.gargoylesoftware.htmlunit.html.DomNode.remove(DomNode.java:860)
at com.gargoylesoftware.htmlunit.javascript.host.NodeImpl.jsxFunction_removeChild(NodeImpl.java:245)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:474)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:185)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:173)
at org.mozilla.javascript.Context.evaluateString(Context.java:1196)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:346)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:468)
at org.mozilla.javascript.Context.call(Context.java:577)
at org.mozilla.javascript.Context.call(Context.java:499)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:354)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:728)
at com.gargoylesoftware.htmlunit.javascript.host.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:114)
at java.lang.Thread.run(Thread.java:619)
at com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:120)
Any ideas?
Logged In: YES
user_id=950730
Originator: NO
Please submit a test case, so we have a common ground.
Logged In: YES
user_id=1941470
Originator: YES
File Added: Crawler.java
Logged In: YES
user_id=950730
Originator: NO
Latest SVN version (http://build.canoo.com/htmlunit/artifacts) does not throw an error now.