Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » "window.external.callJava is not a function" error when invoking BrowserFunction in JS(Error when trying to call BrowserFunction in javascript, because window.external.callJava is not in the DOM)
"window.external.callJava is not a function" error when invoking BrowserFunction in JS [message #907465] Tue, 04 September 2012 04:05 Go to next message
Stella Lok is currently offline Stella LokFriend
Messages: 10
Registered: September 2012
Junior Member
Hi,

I am having a problem invoking a BrowserFunction in Javascript. The BrowserFunction is bound to an SWT.Mozilla Browser in my custom Eclipse plugin code. I have XULRunner 1.9.2 installed.

This BrowserFunction is bound to the Javascript name "ready()".

When I run the Eclipse plugin on Eclipse Juno, point the browser to a page with Firebug Lite installed, and get the value of ready().toString(), I can see the Javascript code that the SWT library injected:

function ready() { 
    var result = callJava(42, "73292d9a3e55b6faad4aedfd7f9b22", Array.prototype.slice.call(arguments)); 
     if (typeof result == "string" && result.indexOf("org.eclipse.swt.browser.error") == 0) { 
          var error = new Error(result.substring(29)); 
          throw error; 
     } 
     return result; 
}


I can also see that window.callJava is defined when I print window.callJava.toString():

function callJava(index, token, args) {
     return external.callJava(index, token, args);
}


However, once I try to call ready() (or in fact any BrowserFunctions), I will get the error that "window.external.callJava is not a function". When I use Firebug Lite to inspect my DOM, I can see that indeed, window.callJava is in my DOM, but not window.external.callJava.

I also experience the same "window.external.callJava is not a function" error on Eclipse 3.7, although the injected code for ready() is slightly different due to the different version of SWT used.

The strange thing is that this issue only happens on one computer, a 64-bit Windows 7 PC running 32 bit versions of Eclipse 3.7 & Eclipse Juno. I do not have any problem calling ready() on other computers I have tested, including another Windows 7 64-bit computer running 32 bit Eclipse 3.7 & Eclipse Juno and XULRunner 1.9.2 as well. On these computers, window.external.callJava is present in the DOM, and when I print out window.external.callJava.toString() in Firebug lite, I get:

function callJava() {
     [native code]
}


This leads me to wonder if there is something wrong with the SWT DLLs on the computer that ready() is failing on. However, the DLLs that are loaded when I run my Eclipse plugin come from the SWT bundles in the Eclipse plugins folder, which I have not changed. For Eclipse Juno, the SWT bundles in my Eclipse plugins folder are org.eclipse.swt.win32.win32.x86_3.100.0.v4233d.jar and org.eclipse.swt_3.100.0.v4233d.jar, and the SWT DLLs loaded were swt-gdip-win32-4233.dll, swt-win32-4233.dll and swt-xulrunner-win32-4233.dll.

If anyone could advise on this issue, I would greatly appreciate it! Please feel free to ask if you need any additional information as well.

[Updated on: Tue, 04 September 2012 04:09]

Report message to a moderator

Re: "window.external.callJava is not a function" error when invoking BrowserFuncti [message #908619 is a reply to message #907465] Wed, 05 September 2012 17:01 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Stella,

My guess is that the "external" XPCOM component is not being registered
properly. See if file
C:\Users\<currentUser>\AppData\Roaming\Mozilla\eclipse\components\external.xpt
exists on your file system. If it doesn't then either the attempt to
write it there is failing for some reason, or you are running your app
with an SWT that's from somewhere other than the
o.e.s.win32...v4233d.jar jar (eg.- you have the org.eclipse.swt project
loaded in your workspace, etc.). Manually putting this external.xpt
file in the specified place on your file system could serve as a
workaround (this file can be extracted from the root of
o.e.s.win32...v4233d.jar).

Another thing to try is to use XULRunner 10.x instead of 1.9.2.x
(SWT/Eclipse Juno only), which will likely work because it no longer
depends on finding the previously-mentioned external.xpt file. If you
try to use XULRunner 10 then you must explicitly point at (it will not
be auto-detected) as described in
http://www.eclipse.org/swt/faq.php#specifyxulrunner .

HTH,
Grant


On 9/4/2012 12:05 AM, Stella Lok wrote:
> Hi,
>
> I am having a problem invoking a BrowserFunction in Javascript. The
> BrowserFunction is bound to an SWT.Mozilla Browser in my custom Eclipse
> plugin code. I have XULRunner 1.9.2 installed.
>
> This BrowserFunction is bound to the Javascript name "ready()".
>
> When I run the Eclipse plugin on Eclipse Juno, point the browser to a
> page with Firebug Lite installed, and get the value of
> ready().toString(), I can see the Javascript code that the SWT library
> injected:
>
> function ready() { var result = callJava(42,
> "73292d9a3e55b6faad4aedfd7f9b22",
> Array.prototype.slice.call(arguments)); if (typeof result ==
> "string" && result.indexOf("org.eclipse.swt.browser.error") == 0) {
> var error = new Error(result.substring(29)); throw
> error; } return result; }
>
>
> I can also see that window.callJava is defined when I print
> window.callJava.toString():
>
> function callJava(index, token, args) {
> return external.callJava(index, token, args);
> }
>
>
> However, once I try to call ready() (or in fact any BrowserFunctions), I
> will get the error that "window.external.callJava is not a function".
> When I use Firebug Lite to inspect my DOM, I can see that indeed,
> window.callJava is in my DOM, but not window.external.callJava.
>
> I also experience the same "window.external.callJava is not a function"
> error on Eclipse 3.7, although the injected code for ready() is slightly
> different due to the different version of SWT used.
>
> The strange thing is that this issue only happens on one computer, a
> 64-bit Windows 7 PC running 32 bit versions of Eclipse 3.7 & Eclipse
> Juno. I do not have any problem calling ready() on other computers I
> have tested, including another Windows 7 64-bit computer running 32 bit
> Eclipse 3.7 & Eclipse Juno and XULRunner 1.9.2 as well. On these
> computers, window.external.callJava is present in the DOM, and when I
> print out window.external.callJava.toString() in Firebug lite, I get:
>
> function callJava() {
> [native code]
> }
>
> This leads me to wonder if there is something wrong with the SWT DLLs on
> the computer that ready() is failing on. However, the DLLs that are
> loaded when I run my Eclipse plugin come from the SWT bundles in the
> Eclipse plugins folder, which I have not changed. For Eclipse Juno, the
> SWT bundles in my Eclipse plugins folder are
> org.eclipse.swt.win32.win32.x86_3.100.0.v4233d.jar and
> org.eclipse.swt_3.100.0.v4233d.jar, and the SWT DLLs loaded were
> swt-gdip-win32-4233.dll, swt-win32-4233.dll and
> swt-xulrunner-win32-4233.dll.
>
> If anyone could advise on this issue, I would greatly appreciate it!
> Please feel free to ask if you need any additional information as well.
Re: &quot;window.external.callJava is not a function&quot; error when invoking BrowserFuncti [message #908813 is a reply to message #908619] Thu, 06 September 2012 03:42 Go to previous message
Stella Lok is currently offline Stella LokFriend
Messages: 10
Registered: September 2012
Junior Member
Hi Grant,

Thanks so much for your advice! I found the external.xpt file in the location you mentioned, and also did a comparison with the one in the o.e.s.win32...v4233d.jar, but there was no difference. Then, I tried using XULRunner 10.0.2 instead, and the error does not occur anymore Smile
Previous Topic:[solved]Problem with getting started - swt is not built
Next Topic:nsIWebBrowser webBrowser = (nsIWebBrowser)browser.getWebBrowser() always retunrs null
Goto Forum:
  


Current Time: Thu Apr 25 10:43:50 GMT 2024

Powered by FUDForum. Page generated in 0.04579 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top