Applet debugging issue- applet security warning not displaying when certificates removed - java

We've got a signed java applet that is called from as aspx via javascript (We're not really a Java development shop, were mainly C# devs).
I'm needing to debug through this applet but I'm having an isue that is not beeing seen on my colleagues machines.
To attach the netbeans debugger to the applet we've traditionally removed all certifcates from the 'Trusted Certificates' store via the Java Control panel, deleted any cached applets (via the Java Control Panel) and then when the applet is downloaded and run, we see the security warning. At this point we able to attach the netbeans debugger, okay the security warnings (not checking the 'always trust' checkbox) and then having hit a breakpoint within the applet code, debug from there.
However, whatever I do I'm not seeing the security warnings, which makes it a bit hard to attach to the applet. I've removed our certificate, zapped any cached applets, I've even 'clutched at straws' and removed and reinstalled the JDK (we're using 1.6 update 7, update 10 and update 20; all updates we know work with our implementation). I just can't get the security warning to appear.
It's like I've got an 'always trust' flag permanently switched on.
Any ideas gratefully received.

The security warning comes only when the applet is signed. Otherwise the applet does not have any privileges, so it is not considered necessary to show the warning.
You could simply sign your applet with a new (untrusted, self-signed) key, maybe this helps.

You might try launching the applet using (non-embedded) Java Web Start. Launching with JWS you will lose JS functionality, but should regain easy control over the permissions.

Sorry, not a direct answer to your question, but if what you want is to pause the JVM at startup for debugging, you could use the suspend=n option in the JVM options, as in something like:
-Djava.compiler=NONE -Xnoagent -Xdebug -Xrunjdwp:transport=dt_socket,address=2502,server=y,suspend=n
That way, the JVM suspends automatically, waiting for a connection from the debugger.

Related

Hide java confirm dialog in signed applet

I have an applet that receives an XML that serialized a JasperPrint object and print it using printservices. The applet is signed and the certificate is imported in house.
This applet is in a Web application that call it using javascript and it runs in terminals with Windows XP.
The problem is that when you use the applet always displays the prompt to run the application and users have to confirm to print.
Is there any way around this without ever having to confirm?
UPDATE:
i google the problem and i see that applet is dying (like #user3712670 says),
there are another alternative to run java code on client pc from a web page?
i need to use it locally
Short answer: no.
Any settings for those confirmation dialogs are client-side, so there's nothing you can do in your code or on your server to prevent them.
You might be able to get rid of some of them by making your clients change their security settings, but this is probably not advised. And you probably can't get rid of all of them.
You can check the plugin settings for the particular browser you're running, and you can check the Java security settings from the Control Panel.
The real answer is that applets are a dying technology, and trying to make them work is a bit like plugging up the holes in a sinking ship.

Java Installed vs Java Enabled in browser

Is there a way to detect if java is installed on your machine or if java is disabled on the browser. We use java applets in our application but before the applet is loaded we use "deployJava.js". Sadly even if Java is disabled on the browser it says java is not installed.
So is there way to differentiate if Java is installed or Java is disabled, preferably using javascript. I have also tried using "navigator.javaEnabled()" but it gives me the same result as using "deployJava.js".
You can't.
And that would be very annoying if you could. There's already enough information leaking from the browser to the page, if it started telling people what I have installed but that I have ostensibly disabled, that would be very annoying.
I guess it could be possible and useful to envision an API for that, but in the current state there isn't any: either the plugin is here to be used, or it isn't. It doesn't matter whether it's installed or not.
I guess you'll have to work around it by stating in your user-facing messages that Java either needs to be installed or enabled. Or you could offer to download a diagnostic tool to run it and check it locally, that could be another working alternative, though with the obviously annoying extra-steps to perform (and an additional tool for you to support).
Add a redirect to the HTML page in question. Redirect to javaNotEnabledOrNotInstalled.html (but think of a less descriptive and silly name for it).
Early in the applet init(), call JS to cancel the redirect.
Note also that in the traditional applet element..
<applet
code=..
width=..
height=..
alt='Java is installed but disabled!'>
No Java Plug-In installed in this browser. Get Java free from..
</applet>
In this circumstance, if Java is not installed at all, the user should see..
No Java Plug-In installed in this browser. Get Java free from..
However if Java is installed but disabled, they should see..
Java is installed but disabled!
Here is something js window.navigator.plugin

How to detect if browser will block java applet due to a need for update

In general, browsers (I see this esp. with Safari) are kind enough to inhibit a Java applet from running if it senses that a security related update for Java exists. It seems to do this quietly... my applet just "sits-and-spins" in the browser window - never executes. Is there a way, preferably via JavaScript, to programmatically determine whether or not this condition will exist (so that, for example, applet loading can be skipped and some kind of informational message can be displayed)?
In my particular case, my applet quietly did nothing when launched with Java 1.6.0_37 (on Mac OSX 10.6, Safari 5.1.7). As soon as I updated to Java 1.6.0_43, the applet ran without incident.
The best approach is generally to poll for the existence of the applet using Javascript, and take alternate action after a specific time.
Note that the Deployment Toolkit Script is intended to ensure a valid Java version and run the applet while providing feed-back to the user, so it would be a better overall approach to deploying the applet.

New Java applet plugin not being used?

I am deploying a signed & trusted applet. We need to run the applet in a separate JVM & increase the heap size. Setting separate_jvm & java_arguments works on our local boxes. Curiously we have clients that though they are using 1.6.0_15 don't seem to be running the new plugin architecture.
When I check their Java config, "use next-generation plugin" is checked & IE7's option "use Java 1.6.0_15 for applet plugin" is also checked. Nothing seems obviously wrong. The Java console also reports the correct version, but neither separate_jvm nor java_arguments are respected.
Just as a sanity check we wrapped the applet in a JNLP & set up our web page to serve the applet with a jnlp_href. The applet tag had a bogus code parameter to ensure the JVM was actually running the JNLP. The Java console complains that it cannot find the bogus class when it should be properly loading the JNLP.
Are there security settings or something else that might cause what I'm seeing?
I'm afraid I've just a few suggestions rather than an absolute answer.
The Java virtual machine version
and plug in version can be
different. Go to Control Panel,
Java, Runtime Environment settings.
When you check the console it may
show the two different versions.
The new plugin architecture would
depend on browser, Opera doesn't use
it at all, for example. IE7 does
though. So check which browser it
works on.
Java has got corrupted due to
repeated installs and uninstalls.
Pretty common complaint I've found.
If you have control over one of the
machines you should uninstall every
Java. Restart machine. Install
latest Java.

How to debug/log/trace an applet loading problem?

Recently two of our clients have reported problems with our applets. Looking at the java plugin console it is full of ClassNotFoundException so none of our code is executed.
I've been able to reproduce the stack trace using a virtual pc image with 0 free space on disk, but the problem goes away as I restore some disk space, and the users tell me that their disk is not full; they are able to create new files.
Our applet requires java 6, and the problem has appeared with updates 1, 10 and 14 of the jre. We have also tried different browsers (IE and Firefox), clearing the browser and java caches, ...
How can I debug or trace what is the jvm doing to load our applet?
I suppose that the problem lies on some security directive on windows so I'm using Sysinternal's Process Monitor to log the activity but I don't really know where to look at.
The Java cache is most likely messed up. Open Java in the Control Panel and get rid of all temporary files to see if it goes away.
Logging in the Java Console for loading applets can be enabled which helps quite alot (even if the plugin is extremely cryptic). See http://java.sun.com/javase/6/docs/technotes/guides/deployment/deployment-guide/tracing_logging.html
I've been looking at the plugin source from the JDK and I've found that there is additional debug info available in the logs setting the environment variable JPI_PLUGIN2_DEBUG.
Unfortunately I still only see ClassNotFound exceptions.
I've found a piece of the plugin code that swallows all exceptions, so maybe my users problem is there...
had similar problems a while ago. In our case, the problem seems to be how the applet tag is set up on the web page. If it is in a wrong order or contains the codebase attribute, it fails with 6u10+. This works for us:
<applet name="DMGANTT" archive="DMGantt.zip" code="dm.applet.DMGanttApplet"
width='100%' height='100%' mayscript="mayscript">
We had a similar problem with one of our clients. We discovered that it was a strange bug in some versions of Java related to proxy configuration on the client. See this article for the details
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6723715
Also, our applet failed with new versions for a different reason.
Now, in similar cases I ask them to check javatester.org, so that I can see if applets (in general) load OK in their browser. If that page loads OK, its a problem on our applet (or page). Else it's a problem in their configuration. I help them anyway but it's easier to debug.

Categories