2
votes

**Update 11/30

This has been acknowledged as a JavaWS bug: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8170522

The Problem

We appear to have uncovered a bug with the Java WebStart implementation on OS X, namely that webstart applications fail to launch external app via Desktop.getDesktop().open(File file) API. This only occurs when the Java WebStart app was launched from its desktop shortcut. Has anyone seen this behavior and/or can suggest a workaround and/or additional avenues of testing?

The Detail

On OS X platform, when using an API to open an external application such as Desktop.getDesktop().open(File file) from within a signed Java Webstart application the external application load always results in a crash of that application when the JavaWS app is launched from its desktop shortcut. When the exact same webstart app is launched directly from the JNLP file or from the cache in the Java Control Panel the external application loads without issue. This problem does not occur on Windows.

It is easy to replicate:

  • Create a simple project with one class (Demo class below). This class only tries to all Desktop.getDesktop().open on an RDP file
  • Bundle into a jar and sign (self sign is ok) (ant script below)
  • Create a simple jnlp file (sample below)
  • Deploy jar and jnlp to a webserver accessed via https
  • Add webserver's domain to Java's exception list so that self signed app will run

Test as follows on OS X client machine:

  • install latest Microsoft Remote Desktop app (v8.0.35) - ensure RDP files are associated with this app
  • ensure the RDP client is closed
  • download/run the jnlp file from the webserver it was uploaded to above
  • JavaWS app will open and successfully open RDP client and load the RDP file
  • ensure RDP client and demo app are closed
  • load the demo app from its desktop icon <=== this is the failure case
  • RDP client will start to open and then crash
  • ensure RDP client and demo app are closed
  • load app from java cache <=== this should have the same behaviour as loading from a desktop icon
  • app will open and successfully open RDP client and load the RDP file

The same behavior has been observed with any command the app can issue that will open another application, i.e. this is not just seen with RDP files/app... when the JavaWS app has been loaded from its desktop shortcut, every mechanism we've tried.

When loaded from JNLP directly or from the Java cache within the Java Control Panel the exact same code works without issue. There are no errors or warnings seen in the code so it appears the external command is issued successfully however the way the JVM is interacting with the OS must differ in the two scenarios.

Can anyone suggest what can be done to change the behavior of the webstart app when loaded from its desktop shortcut and make the Windows and OS X experiences consistent?

Files to replicate the issue are below:

Demo class with the open command:

package com.example;

import java.awt.*;
import java.io.File;
import java.util.logging.Logger;

public enum Demo {

   INSTANCE;

  private static final Logger log = Logger.getLogger(Demo.class.getName());

  public static void main(String[] args) {
  Demo demo = Demo.INSTANCE;
   String filename = System.getProperty("user.home")
  + System.getProperty("file.separator")
  + "test.rdp";
   log.info("opening file: " + filename);
   demo.openFile(new File(filename));
   }

   public void openFile(File file) {
   log.info("Desktop.getDesktop().open(" + file.getAbsolutePath() + ")");
  try {
   if (file.exists()) {
  Desktop.getDesktop().open(file);
   } else {
   log.info("Cannot open file " + file.getAbsolutePath() + " does not exist.");
   }
  } catch (Exception e) {
  e.printStackTrace();
   }
  }

}

Demo JNLP file:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+"
   codebase="https://yourwebserver.example.com/path/to/app"
   href="OpenDemo.jnlp" >
  <information>
  <title>Open Demo</title>
  <vendor>Example</vendor>
  <shortcut online="true" install="true">
  <desktop/>
  </shortcut>
  <update check="timeout" policy="always"/>
  </information>
  <security>
  <all-permissions/>
  </security>
  <resources>
  <java version="1.8+" />
  <jar href="./OpenDemo.jar" main="true" />
  </resources>
  <application-desc
   main-class="com.example.Demo" />
</jnlp>

ANT build file:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Build Open Demo WebStart Application">

  <property name="compiled.basedir" value="../out/production/demo-webstart-app/" />
  <property name="target.jarname" value="OpenDemo.jar" />

   <!-- default the target to be 1.8 -->
   <property name="ant.build.javac.target" value="1.8" />
  <property name="ant.build.javac.source" value="1.8" />

   <!-- bundle the jar -->
   <target name="bundle">
  <jar destfile="../${target.jarname}"
   filesetmanifest="mergewithoutmain"
   basedir="${compiled.basedir}" >

  <include name="com/example/**" />
  <manifest>
  <attribute name="Application-Name" value="OpenDemo" />
  <attribute name="Codebase" value="*" />
  <attribute name="Permissions" value="all-permissions" />
  <attribute name="Caller-Allowable-Codebase" value="*" />
  <attribute name="Entry-Point" value="com.example.Demo" />
  <attribute name="Trusted-Only" value="true" />
  </manifest>
  </jar>
  </target>


   <!-- sign what we have bundled with a self signed CA -->
  <!-- cert created using:
  keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore -storepass opendemo -validity 30 -keysize 2048

  What is your first and last name?
  [Unknown]: OpenDemo
  What is the name of your organizational unit?
  [Unknown]: OpenDemo
  What is the name of your organization?
  [Unknown]: OpenDemo
  What is the name of your City or Locality?
  [Unknown]: OpenDemo
  What is the name of your State or Province?
  [Unknown]: OpenDemo
  What is the two-letter country code for this unit?
  [Unknown]: OD
  Is CN=OpenDemo, OU=OpenDemo, O=OpenDemo, L=OpenDemo, ST=OpenDemo, C=OD correct?
  [no]: yes

  Enter key password for <selfsigned>
  (RETURN if same as keystore password):
  -->
   <target name="sign" depends="bundle">

  <signjar
   jar="../${target.jarname}"
   lazy="false"
   alias="selfsigned"
   keystore="../keystore"
   storepass="opendemo"
   />
  </target>

</project>
1
You seem to have put together a compelling case for a JRE bug. Have you submitted a bug report to the maker of the JRE? - Andrew Thompson
Thanks Andrew, yes I have filed a bug report. - Andy Coates
When you get a link for it, please (don't forget to) edit the question to include it. I must admit that when it comes to bugs in JWS launched projects, my 'go to' solution would be 'specify the version with the fix, as the minimum Java needed to run the app.' (shrugs). - Andrew Thompson
Good job on getting the bug report up. Unfortunately I don't have any ideas on (clever) workarounds to offer. Hopefully Oracle can do better. Once they identify the problem & fix it, the solution (new JRE) will (of course) require forcing a higher minimum version for users on OS X. - Andrew Thompson

1 Answers

0
votes

Problem is specific to Remote Desktop app on Mac. It is the RemoteDesktop client that crashes and not the java process that spawns it. The cause is still unknown.

On windows Remote Desktop is brought up from either web launch, cache viewer launch, or shortcut launch and so does on MAC. But, it crashes in the desktop shortcut case on MAC which is followed up by a crash dialog comes up with options to show details, exit (OK) or re-open.

Work-around: Select re-open to this dialog and Remote Desktop comes up fine.