Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096955

[Mac] ProcessBuilder cannot be used by an FX application started by the launcher produced by FX packager

    Details

      Description

      SceneBuilder 2 is hit by the issue (DTL-6093).
      Basically the SB code uses a ProcessBuilder instance to call "open" on Mac in order to either reveal in the Finder some files, or open them with the appropriate application according file association.
      This is a regression compared to SceneBuilder 1.1 which uses the exact same block of code with Java 7 U40 and FX 2.2.40.
      By using older promoted SceneBuilder 2 I can say with FX 8 b112 the issue was already there.

      I've written sample FX code (attached) that shows of a single Button: when hit it constructs a ProcessBuilder and starts it, which in turn opens a Finder on "/Users".
      This sample works like a charm when run from a terminal (as does SceneBuilder), but as soon as you start it thanks the launcher from FX packager you get a stack at ProcessBuilder start.
      Stack is below; message is "Caused by: java.io.IOException: error=38, Socket operation on non-socket".

      How I did construct the Mac application:
      - install last promoted SceneBuilder 2 (today b08) on the Mac
      - compile UseProcessBuilderFX
      - hack SB app in /Applications/JavaFX\ Scene\ Builder\ 2.0.app/Contents to
          . copy UseProcessBuilderFX.jar in the Java dir
          . replace the Info.plist by the attached one (sole changes are the jar file name, the main Java class name, and removal of security related parameters)

      From there simply start SB app and hit the button: the output is written in /tmp/executeDaemon and the stack in /tmp/executeDaemon.stack.
      What I call output is the full environment of the process, its command and current directory.

      In order to run the application from command line I do like this (JAVA_HOME points to FX 8 b120):
      $JAVA_HOME/bin/java -classpath /Applications/JavaFX\ Scene\ Builder\ 2.0.app/Contents/Java/UseProcessBuilderFX.jar useprocessbuilderfx.UseProcessBuilderFX


      yvesjoansmbp2:Contents yjoan$ cat /tmp/executeDaemon.stack
      Cannot run program "open": error=38, Socket operation on non-socket
      java.io.IOException: Cannot run program "open": error=38, Socket operation on non-socket
          at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
          at useprocessbuilderfx.UseProcessBuilderFX.executeDaemon(UseProcessBuilderFX.java:91)
          at useprocessbuilderfx.UseProcessBuilderFX.open(UseProcessBuilderFX.java:114)
          at useprocessbuilderfx.UseProcessBuilderFX$1.handle(UseProcessBuilderFX.java:42)
          at useprocessbuilderfx.UseProcessBuilderFX$1.handle(UseProcessBuilderFX.java:38)
          at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
          at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
          at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
          at javafx.event.Event.fireEvent(Event.java:204)
          at javafx.scene.Node.fireEvent(Node.java:8175)
          at javafx.scene.control.Button.fire(Button.java:185)
          at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
          at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
          at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
          at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
          at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
          at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
          at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
          at javafx.event.Event.fireEvent(Event.java:204)
          at javafx.scene.Scene$MouseHandler.process(Scene.java:3684)
          at javafx.scene.Scene$MouseHandler.access$1800(Scene.java:3409)
          at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1671)
          at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2462)
          at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:314)
          at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:243)
          at java.security.AccessController.doPrivileged(Native Method)
          at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:345)
          at com.sun.glass.ui.View.handleMouseEvent(View.java:526)
          at com.sun.glass.ui.View.notifyMouse(View.java:898)
      Caused by: java.io.IOException: error=38, Socket operation on non-socket
          at java.lang.UNIXProcess.forkAndExec(Native Method)
          at java.lang.UNIXProcess.<init>(UNIXProcess.java:185)
          at java.lang.ProcessImpl.start(ProcessImpl.java:134)
          at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
          ... 46 more


      The output when it goes well (command line start) is:
      yvesjoansmbp2:Contents yjoan$ cat /tmp/executeDaemon

      executeDaemon - Command of the ProcessBuilder is: open -R /Users

      executeDaemon - Directory of the ProcessBuilder is null

      executeDaemon - Environment of the ProcessBuilder is:
      Apple_PubSub_Socket_Render = /tmp/launch-ysf5xT/Render
      HOME = /Users/yjoan
      JAVA_HOME = /Users/yjoan/designertool/2.0/scenebuilder/scenebuilder-binaries/jdk1.8.0.jdk/Contents/Home
      JAVA_MAIN_CLASS_14161 = useprocessbuilderfx.UseProcessBuilderFX
      LANG = en_US.UTF-8
      LC_ALL = en_US.UTF-8
      LC_CTYPE = UTF-8
      LOGNAME = yjoan
      OLDPWD = /Applications/JavaFX Scene Builder 2.0.app/Contents/Java
      PATH = /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/apache-ant-1.9.2/bin
      PWD = /Applications/JavaFX Scene Builder 2.0.app/Contents
      SECURITYSESSIONID = 186b3
      SHELL = /bin/bash
      SHLVL = 1
      SSH_AUTH_SOCK = /tmp/launch-72UpoO/Listeners
      TERM = xterm-256color
      TERM_PROGRAM = Apple_Terminal
      TERM_PROGRAM_VERSION = 326
      TERM_SESSION_ID = F491B9B9-BAFE-4C07-A161-E3ECEC35FE18
      TMPDIR = /var/folders/2h/f4qpfbnn0n18s12l93tphzh000grx0/T/
      USER = yjoan
      _ = /Users/yjoan/designertool/2.0/scenebuilder/scenebuilder-binaries/jdk1.8.0.jdk/Contents/Home/bin/java
      __CF_USER_TEXT_ENCODING = 0x7E3A0:0:0
      __CHECKFIX1436934 = 1


      The output when it goes wrong (launcher start) is:
      yvesjoansmbp2:Contents yjoan$ cat /tmp/executeDaemon

      executeDaemon - Command of the ProcessBuilder is: open -R /Users

      executeDaemon - Directory of the ProcessBuilder is null

      executeDaemon - Environment of the ProcessBuilder is:
      Apple_PubSub_Socket_Render = /tmp/launch-ysf5xT/Render
      HOME = /Users/yjoan
      JAVA_MAIN_CLASS_14164 = useprocessbuilderfx.UseProcessBuilderFX
      LOGNAME = yjoan
      PATH = /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
      SHELL = /bin/bash
      SSH_AUTH_SOCK = /tmp/launch-72UpoO/Listeners
      TMPDIR = /var/folders/2h/f4qpfbnn0n18s12l93tphzh000grx0/T/
      USER = yjoan
      __CF_USER_TEXT_ENCODING = 0x7E3A0:0:0
      __CHECKFIX1436934 = 1

        Attachments

        1. Info.plist
          3 kB
        2. TestPackager-fxui.zip
          35 kB
        3. UseProcessBuilderFX.java
          4 kB
        4. UseProcessBuilderFX.zip
          163 kB

          Issue Links

            Activity

              People

              • Assignee:
                mhowe Mark Howe (Inactive)
                Reporter:
                yjoan Yves Joan (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: