[ htmlunit-Bugs-1579753 ] JavaScriptBackgroundJob run exception in Window.setTimeout()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ htmlunit-Bugs-1579753 ] JavaScriptBackgroundJob run exception in Window.setTimeout()

SourceForge.net
Bugs item #1579753, was opened at 2006-10-18 16:46
Message generated for change (Comment added) made by oliviermir
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1579753&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Olivier Cailloux (oliviermir)
Assigned to: Nobody/Anonymous (nobody)
Summary: JavaScriptBackgroundJob run exception in Window.setTimeout()

Initial Comment:
Hi,

Thanks for the great job about HTML Unit.

We are currently reviewing the package for use in our
service. It works allright on several web sites... But...

I tried on the isiknowledge website (very complicated,
with frames, cookies, javascript) and can't correctly
simulate here.

This is what I'd like to simulate:
1. load the JCR webpage, that's at
http://portal.isiknowledge.com/portal.cgi?DestApp=JCR&Func=Frame
2. leaving the form as is, press the submit "button"
(which is in fact an image representing a button)
3. I should then reach a page which allows me to choose
a category.

Unfortunately, after simulating the "button" press, I
get an exception. And the page that is reached in the
code is a redirecting page while I was excpecting to
see the "Subject Category Selection" page (this is
probalby due to the onLoad script not working correctly).

Any help is appreciated!
Exception follows, and output of the program and java
test code are attached.

18-oct.-2006 16:24:31
com.gargoylesoftware.htmlunit.javascript.host.JavaScriptBackgroundJob
run
GRAVE: Caught exception in Window.setTimeout()
======= EXCEPTION START ========
Exception class=[org.mozilla.javascript.WrappedException]
com.gargoylesoftware.htmlunit.ScriptException: Wrapped
org.apache.xerces.xni.XNIException (Wrapper definition
for JavaScriptBackgroundJob#1)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:253)
        at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:695)
        at
com.gargoylesoftware.htmlunit.javascript.host.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:106)
        at java.lang.Thread.run(Thread.java:595)
        at
com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:101)
Caused by: org.mozilla.javascript.WrappedException:
Wrapped org.apache.xerces.xni.XNIException (Wrapper
definition for JavaScriptBackgroundJob#1)
        at
org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1693)
        at
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:157)
        at
org.mozilla.javascript.ScriptableObject.setBySetter(ScriptableObject.java:1704)
        at
org.mozilla.javascript.ScriptableObject.put(ScriptableObject.java:239)
        at
com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.put(SimpleScriptable.java:270)
        at
org.mozilla.javascript.ScriptableObject.putProperty(ScriptableObject.java:1396)
        at
org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1432)
        at
org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1422)
        at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2824)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)
        at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
        at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
        at
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160)
        at
org.mozilla.javascript.Context.evaluateString(Context.java:1132)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:249)
        ... 4 more
Caused by: org.apache.xerces.xni.XNIException
        at
org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1921)
        at
org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
        at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
        at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown
Source)
        at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:311)
        at
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226)
        at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
        at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
        at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:431)
        at
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335)
        at
com.gargoylesoftware.htmlunit.javascript.host.Window.jsxSet_location(Window.java:374)
        at
com.gargoylesoftware.htmlunit.javascript.host.Location.jsxSet_href(Location.java:174)
        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:585)
        at
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
        ... 18 more
WrappedException:
org.mozilla.javascript.WrappedException: Wrapped
org.apache.xerces.xni.XNIException (Wrapper definition
for JavaScriptBackgroundJob#1)
        at
org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1693)
        at
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:157)
        at
org.mozilla.javascript.ScriptableObject.setBySetter(ScriptableObject.java:1704)
        at
org.mozilla.javascript.ScriptableObject.put(ScriptableObject.java:239)
        at
com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.put(SimpleScriptable.java:270)
        at
org.mozilla.javascript.ScriptableObject.putProperty(ScriptableObject.java:1396)
        at
org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1432)
        at
org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1422)
        at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2824)
        at script.GargoyleWrapper1(Wrapper definition for
JavaScriptBackgroundJob:1)
        at script(JavaScriptBackgroundJob:1)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)
        at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
        at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
        at
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160)
        at
org.mozilla.javascript.Context.evaluateString(Context.java:1132)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:249)
        at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:695)
        at
com.gargoylesoftware.htmlunit.javascript.host.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:106)
        at java.lang.Thread.run(Thread.java:595)
        at
com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:101)
Caused by: org.apache.xerces.xni.XNIException
        at
org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1921)
        at
org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
        at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
        at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown
Source)
        at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:311)
        at
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226)
        at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
        at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
        at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:431)
        at
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335)
        at
com.gargoylesoftware.htmlunit.javascript.host.Window.jsxSet_location(Window.java:374)
        at
com.gargoylesoftware.htmlunit.javascript.host.Location.jsxSet_href(Location.java:174)
        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:585)
        at
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
        ... 18 more
Inside wrapped exception:
org.apache.xerces.xni.XNIException
        at
org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1921)
        at
org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
        at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
        at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown
Source)
        at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:311)
        at
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226)
        at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
        at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
        at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:431)
        at
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335)
        at
com.gargoylesoftware.htmlunit.javascript.host.Window.jsxSet_location(Window.java:374)
        at
com.gargoylesoftware.htmlunit.javascript.host.Location.jsxSet_href(Location.java:174)
        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:585)
        at
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
        at
org.mozilla.javascript.ScriptableObject.setBySetter(ScriptableObject.java:1704)
        at
org.mozilla.javascript.ScriptableObject.put(ScriptableObject.java:239)
        at
com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.put(SimpleScriptable.java:270)
        at
org.mozilla.javascript.ScriptableObject.putProperty(ScriptableObject.java:1396)
        at
org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1432)
        at
org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1422)
        at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2824)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)
        at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
        at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
        at
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160)
        at
org.mozilla.javascript.Context.evaluateString(Context.java:1132)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:249)
        at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:695)
        at
com.gargoylesoftware.htmlunit.javascript.host.JavaScriptBackgroundJob.run(JavaScriptBackgroundJob.java:106)
        at java.lang.Thread.run(Thread.java:595)
        at
com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:101)
== CALLING JAVASCRIPT ==
GargoyleWrapper1()
======= EXCEPTION END ========


----------------------------------------------------------------------

>Comment By: Olivier Cailloux (oliviermir)
Date: 2006-10-30 18:18

Message:
Logged In: YES
user_id=866169

Hhhmmm that's VERY strange: the exception you are
mentionning (which indeed is different from mine) says that
there is no "isi_main" frame on the given site. But if you
go and check manually the provided site, you will see that
there is indeed such a frame. And my code, here, executes
fine (since several weeks) until the "click" try (which
produces the exception with a delay).

I can't understand why you don't observe the same behavior.
Are you sure you ran the exact same code?

----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2006-10-30 17:33

Message:
Logged In: YES
user_id=402164

locally I don't see any js related exception with your code
but a
com.gargoylesoftware.htmlunit.ElementNotFoundException:
elementName=[frame or iframe] attributeName=[name]
attributeValue=[isi_main].

Can you get htmlunit from SVN and check again? If the
problem persists, try to debug
com.gargoylesoftware.htmlunit-ThreadManager#startThread to
investigate the thrown Exception.

----------------------------------------------------------------------

Comment By: Olivier Cailloux (oliviermir)
Date: 2006-10-26 08:54

Message:
Logged In: YES
user_id=866169

I run on java 5, but the thread handler is not taken into
account: when putting a breakpoint in my handling code (with
the change you suggested here), it never stops there.

I think that the exception is indeed handled somewhere in an
existing package: the marks "EXCEPTION START" - "EXCEPTION
END" does not look like a default java handler. As the
exception is handled, naturally my default handler is not
called.

I attach hereby a java file showing the problem, with the
handler.

----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2006-10-25 16:46

Message:
Logged In: YES
user_id=402164

Do you run on java 5 or 1.4?

With 5 it is possible to use
Thread.setDefaultUncaughtExceptionHandler with a custom
exception handler that would explore the exception.

----------------------------------------------------------------------

Comment By: Olivier Cailloux (oliviermir)
Date: 2006-10-24 13:04

Message:
Logged In: YES
user_id=866169

Just in case this was not clear: I was referring to the
attached code snippet (Main2.java).

----------------------------------------------------------------------

Comment By: Olivier Cailloux (oliviermir)
Date: 2006-10-23 19:55

Message:
Logged In: YES
user_id=866169

Dear mguillem,

Unfortunately, no, I can't look at the orginal cause... Or I
don't know how to do it. Because the exception is raised in
a different thread than the main thread, and this other
thread is set up internally by I don't know exactly what
part of the code (anyway I can't change it). Indeed if I add
a "try / catch (RuntimeException e)" around the problematic
statement, it does not reach the catch part. (Other
illustration: if I remove the sleep statement, the exception
is never raised because - I suppose - the main thread exits
before the other one crashes.)

But isn't the original cause somewhere in the trace I pasted
here? If no, can I somehow access the part of the code where
the new thread is created and the error raised (maybe by
subclassing something, but what)?

----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2006-10-18 22:10

Message:
Logged In: YES
user_id=402164

Can you look at the original cause of the XNIException.
Following should help:

    static Throwable extractNestedException(final Throwable e) {
        Throwable originalException = e;
        Throwable cause = ((XNIException) e).getException();
        while (cause != null) {
            originalException = cause;
            if (cause instanceof XNIException) {
                cause = ((XNIException) cause).getException();
            } else if (cause instanceof
InvocationTargetException) {
                cause = cause.getCause();
            } else {
                cause = null;
            }
        }
        return originalException;
    }


----------------------------------------------------------------------

Comment By: Olivier Cailloux (oliviermir)
Date: 2006-10-18 16:54

Message:
Logged In: YES
user_id=866169

... joining the output of the program as a text file (easier
to read)...

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1579753&group_id=47038

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop