New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 580 link

Starred by 83 users

Issue metadata

Status: Invalid
Owner: ----
Closed: Feb 2013
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Restricted
  • Only users with Commit permission may comment.



Sign in to add a comment

Java Applet to JavaScript communication (liveconnect) is not working.

Reported by gutm...@gmail.com, Sep 3 2008

Issue description

Product Version      : 0.2.149.27 (1583)
URLs (if applicable) : -
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
     Safari 3: DK
    Firefox 3: OK
         IE 7: OK

What steps will reproduce the problem?
1. Embed simple java applet with a string setter function in an html page.
2. Write a JS script that tries to set that filed.
3. Run it.

What is the expected result?
Success in setting the String inside the java code.

What happens instead?
Error in JS, claiming the applet does not have the given setter method.

------------
I'm adding a small example of a java file and html file. Works in FF3 and 
IE6, not in 
Google Chrome.
(Compile with any version you'd like, I tried with java 1.5)

The files should be in the same folder (the .class and .html).
 
TestApplet.java
232 bytes View Download
testHtml.html
538 bytes View Download

Comment 1 by Deleted ...@, Sep 4 2008

I also experienced a problem with a page that contains an applet and has javascript 
routines that are supposed to interact with the applet. From what I could tell when I 
tested it, the interaction between the applet and the javascript functions are not 
executing. The applet is responding as it should to input, but the page does not 
update with the data the applet should be supplying to it.

Comment 2 by gutm...@gmail.com, Sep 4 2008

Br, In my example the applet is *not* responding to the input, because the functions 
are not executing. Please look at the example I added and tell me you you get a 
different result...

Also seen this with my Java applet at www.j2e.com/new

window.onbeforeunload does work with Chrome in simple javascript.
However in my case it does not. My application is a java application.
In order to stop window closure when the user has edited in the
application area, I have to get javascript to communicate with java. I
do this using the DOM, which works fine in Firefox, IE and Safari. The
following example code fails in Chrome at the DOM call. The script
does not echo the following alert, so it appears that Chrome just
kills the script?

<script language="JavaScript1.2" type="text/javascript">
<!--
  //register function with the event handler
  window.onbeforeunload = confirmUnload;

  function confirmUnload(){
       alert("?");  // test we came into this function - we did!

       // Call function in javaApplet to see if document has changed.
Function returns "yes" or "no".
       var c = document.javaApplet.changed();

       alert(c);  // This alert never happens with Chrome, window
just closes. Firefox and IE give this alert with correct value.

       if (c=="yes")
               return 'You have made changes, and they will be lost!';
  }
//-->
</script>


This problem causes our application not to work properly.
This means we can't recommend nore support Chrome as browser, please fix it.

Comment 5 by Deleted ...@, Sep 10 2008

TiddlyWiki users would like to see this one fixed also. It prevents TiddlyWiki from
being able to save.

Comment 6 by keith...@gmail.com, Sep 10 2008

My application with applet liveconnect is not working too. My javascript unable to 
call the method in applet. Please fix it.
Just a "me too" (as a Tiddlywiki user) to increase the visibility of this bug.

Comment 8 by Deleted ...@, Sep 10 2008

Another me too!  This is stopping the adoption of Chrome as default since quite a few
web apps fail!

Comment 9 by darin@chromium.org, Sep 10 2008

Chrome currently requires the latest Java 6 beta from 
Sun:http://java.sun.com/javase/downloads/ea/6u10/6u10RC.jsp

Comment 10 by feng@chromium.org, Sep 10 2008

Have you tried Java 6 beta release?
http://java.sun.com/javase/downloads/ea/6u10/6u10RC.jsp

We are using Java 6 beta (update 10) foe our tests. It is with this version that the
calls failed.

Comment 12 by feng@chromium.org, Sep 10 2008

Status: Assigned
I will take a look into it.
Thanks,
If you need any extra information, don't hesitate to ask.
Ian

Comment 14 by feng@chromium.org, Sep 10 2008

It turns out a silly mistake, the binding code didn't think Applet element is a 
plugin element. I made one-line change in the code and the simple test case you 
provided works fine now.

Before I claim this bug is fixed, do you have some more complicated Java Applets on 
the web that I can test out?

Comment 15 by Deleted ...@, Sep 10 2008

Feng - have you tried the fix with a TiddlyWiki save yet?
Thanks,
Chuck
empty.html
283 KB Download

Comment 16 by feng@chromium.org, Sep 10 2008

kittrellbest: can you provide steps to reproduce the problem you had with TiddlyWiki?

geofftitmuss: can you also provide steps to reproduce the problem? I didn't see the 
dialog when I close the window in Safari.
Ok, to test my case.

Load www.j2e.com/new&beta
Then click on the blank page, and type some text into it eg "j2e in Chrome is really 
cool" ;-)
Then try to close the window.
A dialogue should appear asking if you are sure, you will lose changes...
geofftitmusee: First you need to fix the your website:

document.j2e does not work in Safari and Chrome, you need to change it to window.j2e, 
or document.getElementById('j2e');
geofftitmuss: other that, I can see window.j2e.changed() returns 'yes' or 'no' 
properly with my fix.

Comment 20 by radv...@gmail.com, Sep 10 2008

You can test on a more complex applet that makes extensive use of LiveConnect at
www.upnext.com. Thanks.

Comment 21 by radv...@gmail.com, Sep 10 2008

I should add, you'll know it's working if the applet resizes to fit the available
width of the screen whenever you change the browser window size.

Comment 22 by feng@chromium.org, Sep 10 2008

geofftitmuss: actually this is a webkit "bug" or not. document.j2e should work, but 
in your code, <object ...> is not closed by </object>. It works in FF, but not work 
in Webkit (Safari). I am going to file a bug to WebKit.

Thanks for reporting.

Comment 23 by feng@chromium.org, Sep 11 2008

Filed webkit bug about <object> https://bugs.webkit.org/show_bug.cgi?id=20775

radvani, the resize does not work yet. there are other issues. I will take another look.

JS code on http://upnext.com is obfuscated. Do you have snippets of JS code that talk to applets?

Comment 24 by gutm...@gmail.com, Sep 11 2008

The <object> requiring </object> is not a bug - it's following the standard. The only 
reason FireFox allows it is that Explorer does (along with many other things that 
should not be allowed) and web-programmers got used to that. 
Valid HTML always has a </object>, or if you're looking at something like <img 
src...> then it should end like this: <img src="..." ... />.
-> actually this is a webkit "bug" or not. document.j2e should work, but 
-> in your code, <object ...> is not closed by </object>.

In my code the <object> is closed by </object>.

Look carefully, the <object> line is done by a document.writeln in javascript.
the </object> is in the original html. This is done for a reason, my server generates 
the html with some parameters in it. The javascript is static and reused.

Safari on Mac OS is quite happy with with.
-> document.j2e does not work in Safari and Chrome, you need to change it to 
window.j2e, 
-> or document.getElementById('j2e');

I have changed my code from document.j2e to document.getElementById('j2e').
My applet now works on Chrome.

document.j2e should have worked and must be a Chrome and Safari(Windows) bug.

thanks for your help.
I've tested TiddlyWiki with the latest nightly, and the JavaScript bridge is still not working correctly.

The code in question is:

if(document.applets["TiddlySaver"]) {
var s= String(document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8"));
return s;
}

When I alert document.applets["TiddlySaver"], it comes out as an HTMLAppletElement, and the Java console indicates that the applet is being 
loaded and initialised. When I try the code above to invoke a method exposed by the applet, the error I get is:

Uncaught TypeError: Object #<an HTMLAppletElement> has no method 'loadFile'

Comment 28 by feng@chromium.org, Sep 11 2008

geofftitmuss:
document.j2e bug is filed to webkit: https://bugs.webkit.org/show_bug.cgi?id=20775

radvani:
http://www.upnext.com seems working on my local build, the map resizes when the 
window resizes.

jeremy.ruston:
The code seems fine to me, and it shouldn't throw the exception. Do you have easy 
reproducible steps?
Where do we download the latest build to test?

thanks

Comment 30 by feng@chromium.org, Sep 12 2008

Yes, you can. Here is a recent build that has the fix:
http://build.chromium.org/buildbot/snapshots/chromium-rel-xp/2115/

You can download chrome-win32.zip and extract it. Start Chrome with a parameter like
chrome.exe --user-data-dir=c:\foo, so it won't mess up with your default profile.

And you can always find the latest build at
http://build.chromium.org/buildbot/waterfall/
looking for 'archived build' and click on the [download] below it.



Thanks for the build info,

Here is what we get from our live connect based platform;

1. The JRE loaded with Java Kernel upon plug-in component request from the chrome does not work and throws a 
cryptic exception from inside java plugin2 code.
2. The offline installation from http://java.sun.com/javase/downloads/ea/6u10/6u10rcDownload.jsp#6u10JREs of 
JRE runs liveconnect fine with the snapshot build; however, it can not instantiate live connect for the 
second applet. This means that it does not allow two applets to make a live connection on the same page or 
from different iframes from the same domain.
3. Our platform is quite complex and works fine with Safari for windows. I can provide a private demo to you 
to test the liveconnect with it. Just drop a message here I will email demo information to you.

thanks
Bora
By the way, the second execution of the scenario I have listed on item 2 has failed 
with the result of item 1. Here is the cryptic exception I have mentioned.

java.lang.Exception: comp is null
	at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown 
Source)
	at java.lang.Thread.run(Unknown Source)



Comment 33 by Deleted ...@, Sep 12 2008


recent build works fine with javagotchis (reloading the given nr in the url)!

http://www.javagotchi.com/?1000

thank you and looking forward to the next release...

greetinx from germany

Comment 34 by Deleted ...@, Sep 12 2008

sorry i was by accident in the wrong browser :|
same bug with javagotchis: :(

java.lang.Exception: comp is null
	at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Further investigation reveals that there is in fact an initialization problem with 
the applets in chrome. When the said exception is received, pressing on the refresh 
button of the chrome loads the applet successfully. Therefore, the second issue I 
have listed in comment 31 was probably related to this failed initialization attempt 
of the second applet. How is this handled in webKit? is it really totally different?
Thanks very much feng, the applet seems to work perfectly in TiddlyWiki now. Your quick response is much 
appreciated by everyone in the TiddlyWiki community.

Comment 37 by Deleted ...@, Sep 14 2008

The following still will not load:
http://maps.rmlsweb.com/GeoJetElp/sjgeojet.asp?mapName=42&X=-48936082&Y=47782158&address=28282+SW+MOUNTAIN+RD,+97068
Is this the same problem?
Thanks

Comment 38 by feng@chromium.org, Sep 17 2008

sorry, guys, I was a bit busy on other stuff in last a few days.

@boraertun, a private demo will certainly help, please email to feng @ chromium org

To comment 34, do you have a url I can try out?



@dshehane,

I got the same error dialog box in Safari:

GeoJet not loaded successfully.
Check security settings to enable Java Applet and Javascript.

Comment 40 by Deleted ...@, Sep 17 2008

>comment 34
http://www.javagotchi.com/?10020

seem to work good now,
just enter a number between 0 and 999999 after the questionmark, this parameter will
be transferred onload to the applet

thanx!

Comment 41 by Deleted ...@, Sep 18 2008

Should be fixed in 0.2.149.30 according to changelog.
http://google-chrome-changelogs.blogspot.com/

Comment 42 by Deleted ...@, Sep 20 2008

the Jmol community (jmol.sourceforge.net) is VERY happy to see this working, for
example, at http://chemapps.stolaf.edu/jmol/docs/examples-11/new.htm

excellent!

Comment 43 by Deleted ...@, Sep 21 2008

We still cannot get Java to JavaScript execution to work properly in the latest 
Chromium build.  Whenever a script that is invoked from within a Java applet 
encounters a call to a Java method it produces an evaluation error and the script 
fails to execute.

Can this be fixed also?

Comment 44 by Deleted ...@, Sep 23 2008

Anyone out there?  This is serious!

Comment 45 by feng@chromium.org, Sep 25 2008

Hi everyone, sorry for the delay. I am overwhelmed by other stuff.

Amit is our plugin person, and I forwarded all your private messages to him and re-
assign the bug to him.

I will help fix Java plugin bugs when I have free time.

Thanks for reporting, we are not ignoring you.
Labels: -area-unknown Area-Misc
document.applets[] is non-standard.

Comment 48 by amit@chromium.org, Oct 9 2008

document.applets[] is supported in Google Chrome and should work. If someone can 
provide test cases for these issues then it will be very helpful in resolving them.

Thanks!



Comment 49 by Deleted ...@, Oct 11 2008

I provided a test case to Feng, but here it is again...
JSApplet.java
346 bytes View Download
jsapplet.html
223 bytes View Download

Comment 50 by amit@chromium.org, Oct 21 2008

Thanks for the test case. It can be further reduced to:

<html><head><script language="javascript">
function runTest() {
  var g = document.scripter.getGraphics();
  g.setColor(new java.awt.Color(200, 200, 200));
}
</script>
</head>
<body onload="runTest()">
<applet id="app" code="java.applet.Applet" name="scripter"
        width="100" height="100">
</applet>
</body>
</html>

This fails because Chrome doesn't support global Java packages. So it is not possible 
to call 'new java.awt.Color(...)' in Chrome. 

However, I am looking into the newer way to support this using the following syntax: 
'new document.scripter.Packages.java.awt.Color(...)'

New Java plugin enables this syntax and more information about it can be found here: https://jdk6.dev.java.net/plugin2/liveconnect/#PER_APPLET_PACKAGES

Will revisit this later once we have 'Packages' keyword working.


Labels: -Area-Misc Area-WebKit
Looking at this thread, I'm going to take this out of Area:Misc and put it in 
Area:WebKit
Is this related to the Bug I posted?

http://code.google.com/p/chromium/issues/detail?id=6170

Thanks,
Beanie
Ardent user of tiddlywiki and this is currently preventing me from using it in 
Chrome.  Love the 'application' aspect and waned to set up a standalone tiddlywiki 
todo. 

Comment 54 by amit@chromium.org, Mar 2 2009

From the script it does not look like it using 'java.awt.xxx..." pattern so it is not 
related. Also, it happens on Safari too so it could be a webkit issue.

Comment 55 by jon@chromium.org, May 15 2009

Labels: Area-Plugins JavaScript Mstone-2.1 Size-Large

Comment 56 by jon@chromium.org, May 15 2009

Status: Available

Comment 57 Deleted

Comment 58 Deleted

Labels: -mstone-2.1 mstone-3

Comment 60 by darin@chromium.org, May 24 2009

Summary: Java Applet to JavaScript communication (liveconnect) is not working.

Comment 61 by jon@chromium.org, May 29 2009

Status: Assigned
I am not sure if this is related to this but or not, but using the <applet> tag works 
fine with LiveConnect, but using the <object> tag does not seem to work with 
LiveConnect.

eg.
<object name="testObj" type="..." ...>[params]</object>
<script language="Javascript">
javaObj = document.testObj;
alert(javaObj.someTestMethod());
</script>

This code works if <applet> is used instead of <object>. Both work in other browsers 
like Firefox.

Expected result:
An alert box featuring some text returned by the Java applet through LiveConnect.

Actual Result:
Nothing. No code beyond "javaObj.someTestMethod()" runs. Additionally, the developer 
javascript debugger fails to load on the page.

Version: 2.0.172.28

Comment 63 by amit@chromium.org, Jun 1 2009

jimbo2150: have you tried using getElementById()? It may not be an issue with Java 
bindings at all.
Yes, I have tried getElementById(). Oddly enough, in Chrome and Firefox it returns an
HTML object, but not the java object. Attempting to call some Java method gives a
"that method does not exist" error.

Comment 65 by amit@chromium.org, Jun 1 2009

Right, so this is not related to Java live connect. :)

Comment 66 by jon@chromium.org, Jun 5 2009

Labels: -mstone-3 Mstone-X
Status: Available

Comment 67 Deleted

Comment 68 by gke...@gmail.com, Oct 17 2009

None of the example on https://jdk6.dev.java.net/plugin2/liveconnect/ work for me.

Comment 69 by jam@chromium.org, Oct 20 2009

Status: Invalid
We don't ever intend to support LiveConnect in Chrome.  The newest version of the Java 
plugin from Sun removes the need for this, since it uses NPRuntime to allow scripting.

Comment 70 by gke...@gmail.com, Oct 21 2009

I am happy with not suppporting LiveConnect but should the examples provided for the 
new plugin for Sun jvm 1.6 for javascript and Java communication work?  The link in 
comment # 68 is talking about the new plugin and "LiveConnect".  None of these 
examples work in chrome...any plans to support that?

Comment 71 by gke...@gmail.com, Oct 21 2009

Also found this bug which shows that none of the java plugin2 LiveConnect tests 
passing:

http://code.google.com/p/chromium/issues/detail?id=3285#c39
Labels: -Area-Plugins Area-Internals Internals-Plugins

Comment 73 by Deleted ...@, Dec 30 2009

I've found LiveConnect works as long as the <applet> are a part of the static html 
document.  But if I try something like this LiveConnect stops working.

appletinsert = '<applet>...</applet>'
document.getElementByID( 'targetdiv' ).innerHTML = appletinsert;

LiveConnect calls to the javascript work but not from the javascript back to the 
applet.

Can anyone suggest any alternatives that might allow me to dynamically insert the 
applet tag into an html element?  

Thanks. 
jeremy.ruston is incorrect in saying the problem with tiddly wiki is solved. it is 
not :|

the stepts to reproduce the problem: 
1. save the two attached files somewhere (they're the latest version of tiddly wiki)
2. open 'empty.html' (an blank tiddly wiki file) with Chrome
3. edit something (click 'edit' in the upper-right side, change something, and click 
'done')
4. click 'save changes' in the right panel (a confirmation message will appear that 
the file was saved)
5. close the file
6. reopen the file - the change made at step 3 is no more...
TiddlySaver.jar
4.9 KB Download
empty.html
344 KB Download

Comment 75 by Deleted ...@, Apr 16 2010

Having a very similar issue from within GWT code. We have an embedded applet and
successfully callback from the applet to JavaScript and into GWT using this process:
http://code.google.com/support/bin/answer.py?hl=en&answer=75695

However for the opposite direction we can get it to work with every browser except
Google Chrome (ironic, since we are using GWT). 

E.g. none of the following work with Chrome. No errors thrown just nothing happens.
This is with the latest JavaScript plugin (1.6.0_20 at the time of writing) and
Chrome 5.0.xx.

    private static native Object callMethodName() /*-{
           return $doc.applets.ourApplet.methodName();
    }-*/;

    private static native Object call(String methodName) /*-{
           return eval("$doc.applets.ourApplet."+methodName+"()");
    }-*/;


    private static native Object call(String methodName) /*-{
           return eval("$doc.ourApplet."+methodName+"()");
    }-*/;


    private static native Object call(String methodName) /*-{
           return eval("$doc.applets[0]."+methodName+"()");
    }-*/;

    private static native Object call(String methodName) /*-{
           return eval("$doc.applets["ourApplet"]."+methodName+"()");
    }-*/;

Comment 76 by Deleted ...@, Feb 22 2011

I am also using GWT 2.0.4 and I have the same problems. When I try to call an applet method from javascript using jsni, I get the "has no method ..." error. Please fix it!

Comment 77 by Deleted ...@, Mar 3 2011

I also have this problem. Can't communicate with applets via JavaScript. Will not be able to recommend Chrome for our web application. Unless this gets fixed... Thanks.
this is a major issue that needs to be resolved. javascript to java applet communication is essential to many applets.

Comment 79 by Deleted ...@, Apr 13 2011

Chrome Version       : <8.0.552.237>
OS Version: 5.1 (Windows XP)
URLs (if applicable) :
Other browsers tested:
  Add OK or FAIL after other browsers where you have tested this issue:
     Safari 5:Fails
  Firefox 4.x:Success
     IE 7/8/9:Success

What steps will reproduce the problem?
1.In my application's login page when i click login button, it should invoke a method of my applet,which does some validation operation for me.


What is the expected result?
It works fine in IE(all versions), Mozilla(all versions),Chrome(V6).The applet performs some login validation and loads the user's homepage

What happens instead?
In Chrome version 8 , when i click login button , control flows till the place where applet's method is getting invoked.The alert messgs present after the applet method invokation do not get displayed.On Javascript display console,error message getting displayed is 
"Uncaught TypeError:Object #<an HTMLAppletElement> has no method 'method2'"

Please let me know what change has to be dome to resolve this issue.
I have made sure that both java & javascript are enabled in the browser.


3 years and this still hasn't been fixed? This is a pretty significant omission from google chrome. Guess our web application won't be supported on Google Chrome...

Comment 81 by Deleted ...@, Jul 7 2011

Here's a Web page that works in Safari and Firefox and iCab for Mac, but not in Chrome: http://epoch.uky.edu/ace/public/lewisTest.jsp

Note the first applet loads, but the second one does not.  The difference between the two applets is that the first one loads a string into the applet with a <param> tag, whereas the second one calls an applet method called setMol().  

Comment 82 by Deleted ...@, Mar 22 2012

Why is this issue closed and the status invalid? I had the same problem problem with Chrome today (17.0.963.83 m), too. I.E. calling a public applet function from javascript.

I use 

   <script type="text/javascript">
      var attributes = {
         name : 'myApplet',
         codebase : 'applets',
         archive : 'MyApplet.jar',
         code : 'MyApplet.class',
         width : 100,
         height : 35
      };
      var parameters = {
      };
      var version = '1.6';
      deployJava.runApplet(attributes, parameters, version);
      document.myApplet.drawAppletButton();
   </script>

And get the error:
Uncaught TypeError: Object #<HTMLAppletElement> has no method 'drawAppletButton'

But the applet has that method and the code is working in Firefox 11 and IE 9. And it works if I reload the page in Chrome. It simply doesn't at the first load. This needs to be fixed indeed!

Comment 83 by Deleted ...@, Mar 22 2012

Don't know if this is relevant, but deployJava is comming from

<script type="text/javascript" src="http://java.com/js/deployJava.js"></script>

in the header. Sorry for double post, but there is no edit function.

Comment 84 by Deleted ...@, Apr 24 2012

The actual problem may be the applet itself is not initialized because of any run time exceptions in the applet's init() method and that is why the applet communication does not happen via javascript. Check for any run time exceptions using the Java console.

You can enable to show java console when applet gets initialized as described below

On windows, 
Go to Control Panel, Select Java Control Panel and go to Advanced tab and select  Settings> Java Console and select 'Show Console' Radio button.

Comment 85 by Deleted ...@, Aug 1 2012

This continues to be a problem in the latest release of Chrome 21.0.1180.60.  I have verified that no matter how you reference the applet window.appletName, document.appletName or document.getElementById("appletName") public applet methods are not accessible via javascript.  What I found to be interesting is that through Chrome's Developer Tools console, I'm able to access public methods.  I suspect that the problem is related to the implementation of LiveConnect or the interface between javascript and LiveConnect.  Hope to see this addressed in future releases of Chrome; I'd like to formally support Chrome on our intranet.
applet_issue.png
25.7 KB View Download

Comment 86 Deleted

Project Member

Comment 87 by bugdroid1@chromium.org, Oct 14 2012

Labels: Restrict-AddIssueComment-Commit
This issue has been closed for some time. No one will pay attention to new comments.
If you are seeing this bug or have new data, please click New Issue to start a new bug.
Project Member

Comment 88 by bugdroid1@chromium.org, Mar 10 2013

Labels: -Area-WebKit -Area-Internals Cr-Content Cr-Internals
Project Member

Comment 89 by bugdroid1@chromium.org, Apr 6 2013

Labels: -Cr-Content Cr-Blink

Sign in to add a comment