I have extremely strange thing going on with my java application. In summary, the problem is that it sometimes closes itself after 30-60 seconds of work.
The specifics of the situation are as follows:
-
The application is actually launched in applet setting, the applet loads the main application jar, saves it to disk, then launches the actual program via reflection. The applet jar is signed, the application jar is not signed, so I had to override the security manager. The code is as follows:
System.setSecurityManager(new SecurityManager() { @Override public void checkPermission(Permission p) {} }); URLClassLoader loader = new URLClassLoader(new URL[] {mainJarFile.toURI().toURL()}, this.getClass().getClassLoader()); Class<?> app = Class.forName("launch.App", true, loader); Method start = app.getDeclaredMethod("start", URL.class, URL.class); start.invoke(app.newInstance(), codeBase, documentBase); -
The crash happens only when the applet is run via
Citrixconnection to terminal servers. - The crash isn’t, in fact, a crash. In log file, I see that shutdown hooks are started and finished as they should during normal shutdown.
-
If the applet is ran with java console visible and
traceoption on, I see the following message just before the shutdown:security: JSS is not configured network: Connecting https://javadl-esd-secure.oracle.com/update/baseline.version with proxy=HTTP @ FWR200/192.168.0.246:8080 -
After the shutdown hook is started, the application seems to be still running, and I see exceptions like these in the log:
2012.11.13 16:20:07.171 | def.pR.run:1639 | class java.lang.NullPointerException : null sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source) java.security.AccessController.doPrivileged(Native Method) sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source) sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) ... // so on, the exception seems to happen in completely regular app code -
And finally, there was no such problem until those Citrix servers started using
Java 7(specifically, java 7 update 9) instead ofJava 6. Downgrading java doesn’t seem to be an option.
I’m completely lost here. Can somebody at least give me some pointers about solving this problem? What could be the cause? Is there a way to work around these issues?
First, I hope you are authenticating the downloaded application properly before running it (by downloading it over SSL or by verifying it using a digitial signature in which case you might as well sign the jar).
To the problem. It could easily be because youre are running in the applet JVM. The lifecycle of the applet jvm is determined by the browser. So, if you still want to use an applet as the launcher then insert some debugging output in the
Applet.destroy(),Applet.stop()methods of your applet subclass and see if that is related to the shutdown.Another solution could be to launch it using Java Webstart. It really is the best way to launch java applications from the web.