JavaFX UNKNOWN Media Exception Upon Netbeans Upgrade (to Flatpak Version)?

After using Netbeans 12.6 (the Netbeans project was in Limbo) locally for a few years, I actually installed the Netbeans flatpak package (latest update as of 2023-05-05). I’m running on Manjaro (tried .WAV files, but they also don’t work with the same error).

Netbeans Information:

Product Version: Apache NetBeans IDE 17
Java: 11.0.18; OpenJDK 64-Bit Server VM 11.0.18+10
Runtime: OpenJDK Runtime Environment 11.0.18+10
System: Linux version 6.1.25-1-MANJARO running on amd64; UTF-8; en_GB (nb)
User directory: /home/sarah/.netbeans/17
Cache directory: /home/sarah/.cache/netbeans/17


This caused an error in one of the projects I’m working on, and for some reason, in the media player (I suspect some backend issue, not a code issue). I changed the Java platform from JDK19, to JDK20, however, the Netbeans info center seems to report java 11, despite my java -version being: java version "20" 2023-03-21. I’m guessing this has something to do with flatpak being sandboxed, but I’m still not sure if even that is the issue.

What should my next move be? The project ran properly before the Netbeans upgrade, but not after, and no code was changed.

Here is the code that triggers it (last line is where it throws the exception/creation of the media player, all files exist as checked by sout):

public void playRandomTrack() {
        var random = new Random();
        int randomInt = random.nextInt(this.trackPaths.size());
        //Ensure that timecode file is not selected
        while (this.trackPaths.get(randomInt).equals(TIMECODE_FILE)) {
            randomInt = random.nextInt(this.trackPaths.size());
        }
        var path = this.trackPaths.get(randomInt);
        var filePath = path.toString();
        var filePathURI = path.toUri().toString();
        System.out.println("Music Track Loaded: " + filePathURI);
        System.out.println("File exists: " + Files.exists(path));
        var media = new Media(filePathURI);
        var newPlayer = new MediaPlayer(media);

(NOTE: mp3 Files worked prior, and are not corrupted or changed in any way; I’ve played them in VLC to check) And the full program output (other answers which were similar mentioned theming being broken leading to issue on linux):

-------------< com.protonmail.sarahszabo.mizar.core:Mizar >-------------
Building Mizar 1.0
--------------------------------[ jar ]---------------------------------

--- exec-maven-plugin:3.1.0:exec (default-cli) @ Mizar ---
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
May 05, 2023 3:54:46 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @7923f745'
Gtk-Message: 15:54:46.418: Failed to load module "xapp-gtk3-module"
Gtk-Message: 15:54:46.418: Failed to load module "canberra-gtk-module"
Music Track Loaded: file:///home/sarah/NetBeansProjects/Mizar/Music/NIHILISM.A.opus.mp3
File exists: true
May 05, 2023 3:54:51 PM com.protonmail.sarahszabo.mizar.ui.MizarUIUtils lambda$getStandardUncaughtExceptionHandler$2
SEVERE: null
java.lang.RuntimeException: MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
    at com.protonmail.sarahszabo.mizar.ui.MizarUIUtils.lambda$getStandardUncaughtExceptionHandler$2(MizarUIUtils.java:141)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
    at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
    at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:147)
    at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:518)
    at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:421)
    at com.protonmail.sarahszabo.mizar.ui.MizarAudioPlayer.playRandomTrack(MizarAudioPlayer.java:103)
    at com.protonmail.sarahszabo.mizar.ui.MizarAudioPlayer.<init>(MizarAudioPlayer.java:56)
    at com.protonmail.sarahszabo.mizar.ui.MizarUI.lambda$start$1(MizarUI.java:135)
    at com.protonmail.sarahszabo.mizar.ui.MizarUIUtils.lambda$showProgressBarDialog$10(MizarUIUtils.java:461)
    ... 7 more
Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
    at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:297)
    at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118)
    at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:474)
    ... 12 more

POM (<javafx.version>20.0.1</javafx.version>):

<dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-swing</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-media -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-media</artifactId>
            <version>${javafx.version}</version>
        </dependency>

System Specs: System:

  Kernel: 6.1.25-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.2.1
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-6.1-x86_64
    root=UUID=f11386cf-342d-47ac-84e6-484b7b2f377d rw rootflags=subvol=@
    radeon.modeset=1 nvdia-drm.modeset=1 quiet
    cryptdevice=UUID=059df4b4-5be4-44d6-a23a-de81135eb5b4:luks-disk
    root=/dev/mapper/luks-disk apparmor=1 security=apparmor
    resume=/dev/mapper/luks-swap udev.log_priority=3
  Desktop: KDE Plasma v: 5.27.4 tk: Qt v: 5.15.8 wm: kwin_x11 dm: SDDM
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Desktop Mobo: ASUSTeK model: PRIME X570-PRO v: Rev X.0x
    serial: <filter> UEFI: American Megatrends v: 4408 date: 10/27/2022
CPU:
  Info: model: AMD Ryzen 9 5950X socket: AM4 bits: 64 type: MT MCP arch: Zen 3+
    gen: 4 level: v3 note: check built: 2022 process: TSMC n6 (7nm)
    family: 0x19 (25) model-id: 0x21 (33) stepping: 0 microcode: 0xA201016
  Topology: cpus: 1x cores: 16 tpc: 2 threads: 32 smt: enabled cache:
    L1: 1024 KiB desc: d-16x32 KiB; i-16x32 KiB L2: 8 MiB desc: 16x512 KiB
    L3: 64 MiB desc: 2x32 MiB
  Speed (MHz): avg: 2812 high: 4100 min/max: 2200/6358 boost: disabled
    base/boost: 4100/5050 scaling: driver: acpi-cpufreq governor: schedutil
    volts: 1.1 V
Graphics:
  Device-1: NVIDIA GA104 [GeForce RTX 3070] vendor: ASUSTeK driver: nvidia
    v: 530.41.03 alternate: nouveau,nvidia_drm non-free: 530.xx+
    status: current (as of 2023-03) arch: Ampere code: GAxxx
    process: TSMC n7 (7nm) built: 2020-22 pcie: gen: 4 speed: 16 GT/s lanes: 8
    link-max: lanes: 16 bus-ID: 0b:00.0 chip-ID: 10de:2484 class-ID: 0300
  Device-2: AMD Cape Verde PRO [Radeon HD 7750/8740 / R7 250E]
    vendor: VISIONTEK driver: radeon v: kernel alternate: amdgpu arch: GCN-1
    code: Southern Islands process: TSMC 28nm built: 2011-20 pcie: gen: 3
    speed: 8 GT/s lanes: 8 link-max: lanes: 16 ports: active: DP-3,DP-4
    empty: DP-1, DP-2, DP-5, DP-6 bus-ID: 0c:00.0 chip-ID: 1002:683f
    class-ID: 0300 temp: 56.0 C
  Display: x11 server: X.Org v: 21.1.8 with: Xwayland v: 23.1.1
archlinux-java status

It is a flatpak though.

root@MidnightStarSign:/home/sarah# archlinux-java status
Available Java environments:
  java-19-openjdk
  java-20-jdk (default)