Community
Participate
Working Groups
I am the author of project forklabs-javaxpcom [1], a SWT Browser based web crawler. I am currently using XULRunner 1.9.0.13 and SWT 3.650 for Windows, both 32-bit. In the documentation, it is said to set property "org.eclipse.swt.browser.XULRunnerPath" to point to the location of the XULRunner installation. I found out that if the path is "classic", that is without spaces, everything works fine. Also, if the path contains spaces, it works fine. However, if the path contains an accented character (i.e. é or û), I get the stack trace at the end of this post. An easy way to repeat this stack trace is to: 1) clone my project [2], 2) change the name of the XULRunner installation directory to include an accented character (i.e. xulrûnner-1.9.0.13-sdk), 3) update the registration value in class ProjectPageCrawler (around line 105) and 4) run class ProjectPageCrawler. The error seems to occur when one wants to access the underlying document. [1] http://code.google.com/p/forklabs-javaxpcom/ [2] hg clone https://forklabs-javaxpcom.googlecode.com/hg/ forklabs-javaxpcom The stack trace: Exception in thread "main" org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.widgets.Synchronizer.syncExec(Unknown Source) at org.eclipse.swt.widgets.Display.syncExec(Unknown Source) at ca.forklabs.javaxpcom.Crawler.runOnSWTThread(Crawler.java:180) at ca.forklabs.javaxpcom.ProjectPageCrawler.showOff(ProjectPageCrawler.java:90) at ca.forklabs.javaxpcom.ProjectPageCrawler.main(ProjectPageCrawler.java:112) Caused by: java.lang.NullPointerException at ca.forklabs.javaxpcom.Crawler$3.run(Crawler.java:295) at org.eclipse.swt.widgets.Synchronizer.syncExec(Unknown Source) at org.eclipse.swt.widgets.Display.syncExec(Unknown Source) at ca.forklabs.javaxpcom.Crawler.runOnSWTThread(Crawler.java:180) at ca.forklabs.javaxpcom.Crawler.getDocument(Crawler.java:290) at ca.forklabs.javaxpcom.Crawler.getElementById(Crawler.java:312) at ca.forklabs.javaxpcom.ProjectPageCrawler.exploreMainMenu(ProjectPageCrawler.java:64) at ca.forklabs.javaxpcom.ProjectPageCrawler$1.run(ProjectPageCrawler.java:93) at org.eclipse.swt.widgets.RunnableLock.run(Unknown Source) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Unknown Source) at org.eclipse.swt.widgets.Display.runAsyncMessages(Unknown Source) at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at es.ladyr.ladyrbrowser.impl.DisplayManager$1.run(DisplayManager.java:60)
I've confirmed that the basic case of specifying a path name with characters like this works (the Browser comes up). You say that the problem happens when accessing the document, and in your trace the NPE is at ca.forklabs.javaxpcom.Crawler$3.run(Crawler.java:295). What is your code doing here? Is it getting an unexpected null value from a JavaXPCOM call?
I have checked with the current source and the errors doesn't show anymore. It does open up the browser and loads the page but for a moment before closing (but keeps the JVM up and running). It does not do the exploration stage, nor the minimize and the restoration (there are no traces in the console). The correct version of the Crawler class is the version from Sept 13, 2010: http://code.google.com/p/forklabs-javaxpcom/source/browse/src/main/java/ca/forklabs/javaxpcom/Crawler.java?r=eb81fcfedb998cfbb76290967a76d1074fc5a24b Replacing the content of the current class with the one from Sept 13 restores the error. 290 this.runOnSWTThread(new Runnable() { 291 @Override 292 public void run() { 293 Browser browser = Crawler.this.getBrowser(); 294 nsIWebBrowser web_browser = (nsIWebBrowser) browser.getWebBrowser(); 295 nsIDOMWindow window = web_browser.getContentDOMWindow(); 296 nsIDOMDocument document = window.getDocument(); 297 outs[0] = document; 298 } 299 }); It seems that the internal nsIWebBrowser of the Browser object is null. I will investigate why in the current version there are no stack traces but just a window closing.
With the current version of class Crawler, the nsIWebBrowser is still null. However I did find a difference in the way methods are called. In the Sept 13 2010 version of the ProjectPageCrawler: http://code.google.com/p/forklabs-javaxpcom/source/browse/src/test/java/ca/forklabs/javaxpcom/ProjectPageCrawler.java?r=004ecc4989f324755ed6979107632673889e0a63 at line 93 the call of the exploration routine is scheduled on the SWT thread which itself will schedule another call in the SWT thread when requesting the nsIDOMDocument (getElementById() calls getDocument() which schedules code on the SWT thread). I have found out since then that exploring the nsIDOMDocument does not need to be done in the SWT thread, only getting it needs to be. I hope this helps.
Xulrunner is no longer supported. Closing. Please open new bug if you have issues running with supported web engine.