Message5086

Author techniq
Recipients techniq
Date 2009-09-02.13:42:59
SpamBayes Score 3.6917218e-08
Marked as misclassified No
Message-id <1251898980.59.0.325654996509.issue1455@psf.upfronthosting.co.za>
In-reply-to
Content
I'm in the process of migrating some JRuby scripts over to Jython, but 
found the HtmlUnit java jar I rely on does not work with Jython (I've 
tested it with 2.5.0, 2.5.1, and 2.5b1).  HtmlUnit's website is at 
http://htmlunit.sourceforge.net.  I am using htmlunit-2.5.

A script to test the functionality:
############################
import java
import sys,os

directory = 'C:/Downloads/Java/htmlunit-2.5/htmlunit-2.5/lib/'
for file in os.listdir(directory):
    sys.path.append(os.path.join(directory, file))

from com.gargoylesoftware import htmlunit

browser = htmlunit.WebClient()
browser.getPage("http://www.google.com")
############################

And the exception stack trace I receive:
############################
Sep 2, 2009 9:38:22 AM 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration loadConfiguration
SEVERE: Error when loading JavascriptConfiguration.xml
java.lang.NullPointerException
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.getConfigurationFileAsReader(J
avaScriptConfiguration.java:258)
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.loadConfiguration(JavaScriptCo
nfiguration.java:179)
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.<init>(JavaScriptConfiguration
.java:138)
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.getInstance(JavaScriptConfigur
ation.java:236)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.init(JavaScrip
tEngine.java:156)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$000(Jav
aScriptEngine.java:68)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$1.run(JavaScri
ptEngine.java:130)
        at 
net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:515
)
        at 
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFa
ctory.java:507)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(Jav
aScriptEngine.java:141)
        at 
com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1107)
        at 
com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImp
l.java:99)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:268)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultP
ageCreator.java:127)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageC
reator.java:101)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.ja
va:442)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:329)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:386)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:371)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:17
5)
        at org.python.core.PyObject.__call__(PyObject.java:355)
        at org.python.core.PyMethod.__call__(PyMethod.java:215)
        at 
org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
        at org.python.core.PyMethod.__call__(PyMethod.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:397)
        at org.python.core.PyObject.__call__(PyObject.java:401)
        at org.python.pycode._pyx0.f$0(webclient_test.py:11)
        at org.python.pycode._pyx0.call_function(webclient_test.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1204)
        at 
org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:200)
        at org.python.util.jython.run(jython.java:246)
        at org.python.util.jython.main(jython.java:129)
java.lang.NullPointerException
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.getConfigurationFileAsReader(J
avaScriptConfiguration.java:258)
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.loadConfiguration(JavaScriptCo
nfiguration.java:179)
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.<init>(JavaScriptConfiguration
.java:138)
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.getInstance(JavaScriptConfigur
ation.java:236)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.init(JavaScrip
tEngine.java:156)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$000(Jav
aScriptEngine.java:68)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$1.run(JavaScri
ptEngine.java:130)
        at 
net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:515
)
        at 
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFa
ctory.java:507)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(Jav
aScriptEngine.java:141)
        at 
com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1107)
        at 
com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImp
l.java:99)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:268)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultP
ageCreator.java:127)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageC
reator.java:101)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.ja
va:442)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:329)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:386)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:371)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:17
5)
        at org.python.core.PyObject.__call__(PyObject.java:355)
        at org.python.core.PyMethod.__call__(PyMethod.java:215)
        at 
org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
        at org.python.core.PyMethod.__call__(PyMethod.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:397)
        at org.python.core.PyObject.__call__(PyObject.java:401)
        at org.python.pycode._pyx0.f$0(webclient_test.py:11)
        at org.python.pycode._pyx0.call_function(webclient_test.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1204)
        at 
org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:200)
        at org.python.util.jython.run(jython.java:246)
        at org.python.util.jython.main(jython.java:129)
Sep 2, 2009 9:38:25 AM 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$1 run
SEVERE: Exception while initializing JavaScript for the page
java.lang.IllegalStateException: Configuration was not initialized - see 
log for details
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.<init>(JavaScriptConfiguration
.java:142)
        at 
com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigu
ration.getInstance(JavaScriptConfigur
ation.java:236)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.init(JavaScrip
tEngine.java:156)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$000(Jav
aScriptEngine.java:68)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$1.run(JavaScri
ptEngine.java:130)
        at 
net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:515
)
        at 
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFa
ctory.java:507)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(Jav
aScriptEngine.java:141)
        at 
com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1107)
        at 
com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImp
l.java:99)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:268)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultP
ageCreator.java:127)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageC
reator.java:101)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.ja
va:442)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:329)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:386)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:371)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:17
5)
        at org.python.core.PyObject.__call__(PyObject.java:355)
        at org.python.core.PyMethod.__call__(PyMethod.java:215)
        at 
org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
        at org.python.core.PyMethod.__call__(PyMethod.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:397)
        at org.python.core.PyObject.__call__(PyObject.java:401)
        at org.python.pycode._pyx0.f$0(webclient_test.py:11)
        at org.python.pycode._pyx0.call_function(webclient_test.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1204)
        at 
org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:200)
        at org.python.util.jython.run(jython.java:246)
        at org.python.util.jython.main(jython.java:129)
Traceback (most recent call last):
  File "webclient_test.py", line 11, in <module>
    browser.getPage("http://www.google.com")
Exception class=[java.lang.IllegalStateException]
com.gargoylesoftware.htmlunit.ScriptException: Configuration was not 
initialized - see log for details
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$1.run(JavaScri
ptEngine.java:134)
        at 
net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:515
)
        at 
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFa
ctory.java:507)
        at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(Jav
aScriptEngine.java:141)
        at 
com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1107)
        at 
com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImp
l.java:99)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:268)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultP
ageCreator.java:127)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageC
reator.java:101)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.ja
va:442)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:329)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:386)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:371)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

com.gargoylesoftware.htmlunit.ScriptException: 
com.gargoylesoftware.htmlunit.ScriptException: Configuration was not 
init
ialized - see log for details
############################
History
Date User Action Args
2009-09-02 13:43:00techniqsetrecipients: + techniq
2009-09-02 13:43:00techniqsetmessageid: <1251898980.59.0.325654996509.issue1455@psf.upfronthosting.co.za>
2009-09-02 13:43:00techniqlinkissue1455 messages
2009-09-02 13:42:59techniqcreate