1

i've created a java applet last year for a socket connection from a web application to a local running java server. it worked fine.

since the last java updates (7 r21 i guess), i cannot access the methods within javascript anymore. Right now, i reduced the applet to a test applet (without the doPriviligedAction methods) but even this does not work anymore.

The current code is like

import java.applet.*;

public class socketApplet extends Applet {

    public void init() {
        System.out.println("Applet initialisiert.");
    }

    public void start() {
        System.out.println("Applet gestartet.");
    }

    public void paint() {
        System.out.println("Applet aktualisiert.");
    }

    public void stop() {
        System.out.println("Applet angehalten.");
    }

    public void destroy() {
        System.out.println("Applet beendet.");
    }

    public String testApplet() {
        System.out.println("Applet getestet.");
        return "Yep, I'm the Applet.";
    }

}

Before the update i could access methods like testApplet() in javascript like this:

document.socketApplet.testApplet();

The applet is self-signed and embedded with an applet html-tag. It is starting (the java console is opening and prints the debug messages defined in the init, start and paint methods) but i cannot access the testApplet() method. The response in Javascript is "undefined" while the applet exists.

after reading a while (a few days now...) about the new security changes, i've added a manifest.txt with the following content:

Main-Class: socketApplet
Permissions: all-permissions
Codebase: *
Trusted-Library: true

No luck with or without the Trusted-Library attribute.

What do i have to do to enable the access with javascript again?

Edit: The implementation:

<applet id="socketApplet" width="100" height="100" archive="../../socketApplet.jar" name="socketApplet" code="socketApplet" scriptable="true">

I am testing with the newest versions of Firefox and Safari on an up to date Mac OS X machine.

Edit2: i am creating and signing the jar like this enter image description here

Edit3: Okay, now my jar worked a few times (not in a row), i got enter image description here

and in the console enter image description here

But most of the time it does not work. restarting the browser, clearing caches, nothing works. going to test this on another pc now (again).

Edit4: Okay it is running on a virtual machine with windows xp and java 32bit 7u25 - on my 64bit mac just only 1 out of 30 tries.

12
  • What version of what browser is the testing in? What is the HTML used to launch the applet? Commented Sep 3, 2013 at 9:48
  • ty for the fast response, i updated the main-post (see the edit section at the end) Commented Sep 3, 2013 at 10:58
  • 1
    Recommendations: 1) make the applet a non-zero width & height. A 0x0 element in a web page is automatically suspicious, and that could be triggering a higher level of security in the browser, or whatever tools the browser has installed to look for suspicious activity. 2) Add the scriptable="true" attribute to indicate the applet might be called from Javascript. Commented Sep 3, 2013 at 11:14
  • ty but still the same problem Commented Sep 3, 2013 at 11:22
  • Huh.. Does this Oracle page work in those browsers? Commented Sep 3, 2013 at 11:27

1 Answer 1

1

Okay i found the source of all evil...

it had nothing to do with the applet. the confusing situation was that it worked in firefox on windows and not in firefox on the mac (same FF versions, same java versions). Safari on my mac didn't work because the plugin was disabled...

So it was a Firefox on mac problem only. I've tested different situations and the applet worked when writing the applet code above into a html page. Before, i've created the applet dynamically (what is necessary in the software):

    var applet = document.createElement('applet');

    applet.archive      = 'socketApplet.jar';
    applet.id           = 'socketApplet';
    applet.name         = 'socketApplet';
    applet.code         = 'socketApplet';
    applet.scriptable   = 'true';
    applet.width        = '0';
    applet.height       = '0';

    document.body.appendChild(applet);

It works everywhere but not in Firefox on Mac. So as a workaround i have to embed the applet in an iframe and i have to embed the iframe dynamically. that works...

    var mFrame      = document.createElement('iframe');
    mFrame.id       = 'testFrame';
    mFrame.height   = '200';
    mFrame.width    = '400';
    document.body.appendChild(mFrame);
    mFrame.src      = 'frame.html'; // contains the applet code

Next i am going to change the html tag to the object and embed tag for IE support. Thanks for your help Andrew Thompson!

I dislike the iframe version because the access to the applet via javascript is more complex, but it seems like there is no other way around.

I am going to submit a Mozilla bug ticket for this. https://bugzilla.mozilla.org/show_bug.cgi?id=912880

Maybe similar to this one but another situation: https://bugzilla.mozilla.org/show_bug.cgi?id=872969

Sign up to request clarification or add additional context in comments.

1 Comment

Update: They closed the bug ticket as "WONTFIX" - bugzilla.mozilla.org/show_bug.cgi?id=912880#c9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.