Search code examples
javamacosjavafxmacos-catalinajavafx-11

JavaFX-11/macOS: DirectoryChooser crashes 'NSObjectNotAvailableException'


I develop a java application using openjfx modules. I now want to use DirectoryChooser to let the user select several files as an input (code below). Everytime I start the application from the IDE it crashes with the exception below. By crashing I mean totally terminates (not freezing).

I also tried some sample code like this to figure out if there is anything wrong with my implementation but each sample I found gave me the same issue.

I'm unsure if this is a general issue/bug because I saw old bugs, in the oracle bug tracker but they where all marked as fixed.

I would be happy if someone could provide some help on this. I would even be happy with a workaround that just avoids DirectoryChooser if there is any.

Steps to reproduce:

  • create a small Application with the demo code from here.
  • run the application
  • try to open directory chooser

Background information:

  • OS: macOS 10.15.2 Catalina
  • IDE: intelliJ IDEA Ultimate 2019.3

Exception

2020-01-30 17:18:31.288 java[49749:1319417] *** Terminating app due to uncaught exception 'NSObjectNotAvailableException', reason: 'GlassOpenPanel is not a supported subclass for sandboxing'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff364ea8ab __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff6c75b805 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff364ea701 +[NSException raise:format:] + 189
    3   AppKit                              0x00007fff33d43aa9 +[NSSavePanel(Instantiation) _crunchyRawUnbonedPanel] + 368
    4   libglass.dylib                      0x00000001370a2ba6 Java_com_sun_glass_ui_mac_MacCommonDialogs__1showFolderChooser + 358
    5   ???                                 0x0000000117695950 0x0 + 4687747408
    6   ???                                 0x000000011768fa00 0x0 + 4687723008
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Solution

As suggested by mipa increasing the OpenJFX version number solved the problem.
At the moment, it seems working for OpenJFX version 14-ea+7 and 15-ea+1 from MavenCentral


Solution

    1. Why do you use an outdated Version of JavaFX? The current version is 13 and 14 is coming out shortly. EA releases are already available. You can also use them with Java 11.
    2. I tried two of the examples you mentioned with JavaFX 13 and they worked without problem. This may be due to the fact that a bug has been fixed or due to the fact that I am still using MacOS 10.14.6 Mojave.

    Give JavaFX 13 a try and then report back.