JDK-8170522 : Loading JavaWS from desktop shortcut on OSX causes application crashes
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 8u112,9
  • Priority: P3
  • Status: Closed
  • Resolution: Other
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2016-11-11
  • Updated: 2018-03-23
  • Resolved: 2018-03-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8-poolResolved
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
OS X 10.10

A DESCRIPTION OF THE PROBLEM :
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 was 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 issue does not occur on Windows.

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, or with the getDesktop().open API ... when the JavaWS app has been loaded from its desktop shortcut, every mechanism we've tried has the same failure result.

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.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
steps to reproduce:

* 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
* create test.rdp file in user.home folder. The file can be empty.

Test as follows on OS X platform:

* install 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 the desktop icon
* app will open and successfully open RDP client and load the RDP file


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

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>
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
the only workaround is to launch the app from the JNLP or from the Java Cache each time.


Comments
Will not be fixed for JDK 8. Reopen if anyone find this is still an issue that need to be fixed.
23-03-2018

Problem is specific to Remote Desktop app on Mac, it is the RemoteDesktop client that crashes, not the java process that spawns it. Cause is still unknown. I tried this with a simple ".txt" extension after modifying the app to use the property "jnlp.filename" to specifying the file to use. when opening a simple test.txt file: http://oklahoma.us.oracle.com/www/tests/9/8170522/x.jnlp it opened text editor fine on both mac and windows when using wither desktop shortcut or cache viewer. I then tried using a dummy rdp file "test.rdp" (use http://oklahoma.us.oracle.com/www/tests/9/8170522/test.jnlp) On windows Remote Desktop is brought up from either web launch, cache viewer launch, or shortcut launch. On Mac, Remote Desktop app is brought up in all three cases also, but in the desktop shortcut case, it crashes, and 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. due to existing work-around re prioritizing as P3
06-01-2017

On MAC OS X 10.12.1 (Sierra), Checked this for 8u112 b06 as well as 9 ea b146 and could reproduce the issue as reported. 8u101 b13: FAIL 8u102 b14: FAIL 8u112 b16: FAIL 8u122 b08: FAIL 9 ea b146: FAIL To reproduce run the test case (including instructions/steps) from the subsequent link. 1. Install MS Remote Desktop app (v8.0.35 or v8.0.36) Note: Add webserver address to the exception site list 2. Create test.rdp file in user.home folder. The file can be empty 3. Ensure that the RDP client is closed 4. Download/run the OpenDemo.jnlp file 5. JavaWS app will open and successfully open RDP client and load the RDP file Note: Ignore the warnings about invalid rdp file as the file is empty 6. Now close or ensure that the RDP client and demo app are closed 7. Load the demo app from its desktop icon <=== this is the failure case 8. RDP client will start to open and then crash (See attached image) Note: Microsoft Remote Desktop quit unexpectedly 9. Ensure RDP client and demo app are closed 10. Load app from java cache <=== this should have the same behaviour as loading for the first time 11. App will open and successfully open RDP client and load the RDP file The issue is reproducible with 8u as well 9 ea.
30-11-2016