Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger fails to start #191

Open
licht1stein opened this issue Dec 29, 2024 · 8 comments
Open

Debugger fails to start #191

licht1stein opened this issue Dec 29, 2024 · 8 comments

Comments

@licht1stein
Copy link

This happens in a larger of my projects (works fine on the same machine on a smaller project). It fails to launch both in vanilla and full-fledged mode. Trace:

Runtime index system started
Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /home/mb/.openjfx/cache/21.0.4-ea+1/amd64/libprism_es2.so: libXxf86vm.so.1: cannot open shared object file: No such file or directory
java.lang.UnsatisfiedLinkError: /home/mb/.openjfx/cache/21.0.4-ea+1/amd64/libprism_es2.so: libXxf86vm.so.1: cannot open shared object file: No such file or directory
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
	at java.base/java.lang.Runtime.load0(Runtime.java:852)
	at java.base/java.lang.System.load(System.java:2021)
	at com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:220)
	at com.sun.glass.utils.NDec 29, 2024 9:50:06 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @2d233b48'
Loading library glassgtk3 from resource failed: java.lang.UnsatisfiedLinkError: /home/mb/.openjfx/cache/21.0.4-ea+1/amd64/libglassgtk3.so: libXtst.so.6: cannot open shared object file: No such file or directory
java.lang.UnsatisfiedLinkError: /home/mb/.openjfx/cache/21.0.4-ea+1/amd64/libglassgtk3.so: libXtst.so.6: cannot open shared object file: No such file or directory
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
	at java.base/java.lang.Runtime.load0(Runtime.java:852)
	at java.base/java.lang.System.load(System.java:2021)
	at com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:220)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:200)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:142)
	at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:58)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$new$5(GtkApplication.java:173)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
	at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:162)
	at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:40)
	at com.sun.glass.ui.Application.run(Application.java:146)
	at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:290)
	at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:292)
	at javafx.application.Platform.startup(Platform.java:113)
	at flow_storm.debugger.ui.utils$init_toolkit$fn__12604.invoke(utils.clj:27)
	at flow_storm.debugger.ui.utils$init_toolkit.invokeStatic(utils.clj:26)
	at flow_storm.debugger.ui.utils$init_toolkit.invoke(utils.clj:24)
	at flow_storm.debugger.main$start_debugger.invokeStatic(main.clj:81)
	at flow_storm.debugger.main$start_debugger.invoke(main.clj:61)
	at clojure.lang.Var.invoke(Var.java:386)
	at flow_storm.runtime.debuggers_api$start_runtime.invokeStatic(debuggers_api.cljc:684)
	at flow_storm.runtime.debuggers_api$start_runtime.invoke(debuggers_api.cljc:672)
	at flow_storm.api$local_connect.invokeStatic(api.clj:85)
	at flow_storm.api$local_connect.invoke(api.clj:61)
	at flow_storm.api$local_connect.invokeStatic(api.clj:77)
	at flow_storm.api$local_connect.invoke(api.clj:61)
	at user$eval11896.invokeStatic(NO_SOURCE_FILE:12)
	at user$eval11896.invoke(NO_SOURCE_FILE:12)
	at clojure.lang.Compiler.eval(Compiler.java:7700)
	at nrepl.middleware.interruptible_eval$evaluator$run__1760$fn__1771.invoke(interruptible_eval.clj:106)
	at nrepl.middleware.interruptible_eval$evaluator$run__1760.invoke(interruptible_eval.clj:101)
	at nrepl.middleware.session$session_exec$session_loop__1839.invoke(session.clj:229)
	at nrepl.SessioJavaFX toolkit already initialized
Waiting for a dispatch-fn before dispatching events
Waiting for a dispatch-fn before dispatching events

alias:

:storm {:classpath-overrides {org.clojure/clojure nil}
          :extra-deps {com.github.flow-storm/flow-storm-dbg {:mvn/version "4.0.2"}
                             com.github.flow-storm/clojure {:mvn/version "1.12.0"}}
          :jvm-opts ["-Dflowstorm.startRecording=false"
                     "-Dclojure.storm.instrumentEnable=true"
                     "-Dflowstorm.title=Storm"
                     "-Dflowstorm.theme=dark"
                     "-Dflowstorm.fileEditorCommand=emacsclient -n +<<LINE>>:0 <<FILE>>"
                     "-Dflowstorm.jarEditorCommand=emacsclient --eval '(let ((b (cider-find-file \"jar:file:<<JAR>>!/<<FILE>>\"))) (with-current-buffer b (switch-to-buffer b) (goto-char (point-min)) (forward-line (1- <<LINE>>))))'"]}

Any advice on how to solve this?

@jpmonettas
Copy link
Member

Hi! Thanks for reporting the issue.
That is weird, the exception seams OS dependent, looks like it is failing to load some native libs when start JavaFX.

Are both projects running with the same JVM?

Can you share more details about your JVM, like java -version?

Can you also add here the clj -Stree and clj -Spath of both projects detailing the one which works and the one which doesn't?

@licht1stein
Copy link
Author

No, the one which doesn't work is within a nix environment, so the jvm and everything else is separate.

Working:

openjdk 21.0.5 2024-10-15
OpenJDK Runtime Environment (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.5.0.11-1) (build 21.0.5+11, mixed mode, sharing)

Not working (within nix):

openjdk 21 2023-09-19
OpenJDK Runtime Environment (build 21+35-nixos)
OpenJDK 64-Bit Server VM (build 21+35-nixos, mixed mode, sharing)

The path has too much info about the companies behind the projects :(

@jpmonettas
Copy link
Member

jpmonettas commented Dec 30, 2024

The path has too much info about the companies behind the projects :(

No problem!

So I guess the issue isn't related to your projects nor the classpath nor flow-storm, but to the JVM and native libraries on that nix environment.

Here is a very small Clojure JavaFX project you can try to run in that Nix environment, it should also fail :

deps.edn

{:deps {org.openjfx/javafx-controls {:mvn/version "21.0.4-ea+1"}
        org.openjfx/javafx-base {:mvn/version "21.0.4-ea+1"}
        org.openjfx/javafx-graphics {:mvn/version "21.0.4-ea+1"}}}

src/main.clj

(ns main
  (:import [javafx.application Platform]
           [javafx.scene Scene]
           [javafx.stage Stage]
           [javafx.scene.control Label]))

(defn -main []
  (Platform/startup (fn [] (println "JavaFX toolkit initialized")))
  (Platform/runLater
   (fn []
     (let [scene (Scene. (Label. "Hello world") 1024 768)
           stage (doto (Stage.)
                   (.setScene scene))]

       (.show stage)))))

Which you can run with clj -M -m main

It seams there have been similar issues reported on Nix NixOS/nixpkgs#220470 and some hacks to solve them.

Looks like libXtst is missing on that environment.

On my Debian I have it here /usr/lib/x86_64-linux-gnu/libXtst.so.6 which is coming from the package libxtst6 but I don't use Nix, so not sure how it should be there.

I would try to make sure that lib is installed and on the LD_LIBRARY_PATH

@licht1stein
Copy link
Author

Thank you! I'll try it out and report 🙏

@licht1stein
Copy link
Author

Tried it, here's the result:

{:clojure.main/message
 "Execution error (UnsatisfiedLinkError) at java.lang.ClassLoader/loadLibrary (ClassLoader.java:2458).\nno glassgtk3 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.UnsatisfiedLinkError,
  :clojure.error/line 2458,
  :clojure.error/cause
  "no glassgtk3 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib",
  :clojure.error/symbol java.lang.ClassLoader/loadLibrary,
  :clojure.error/source "ClassLoader.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.RuntimeException,
    :message
    "java.lang.UnsatisfiedLinkError: no glassgtk3 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib",
    :at
    [com.sun.javafx.tk.quantum.QuantumToolkit
     startup
     "QuantumToolkit.java"
     300]}
   {:type java.lang.UnsatisfiedLinkError,
    :message
    "no glassgtk3 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib",
    :at [java.lang.ClassLoader loadLibrary "ClassLoader.java" 2458]}],
  :trace
  [[java.lang.ClassLoader loadLibrary "ClassLoader.java" 2458]
   [java.lang.Runtime loadLibrary0 "Runtime.java" 916]
   [java.lang.System loadLibrary "System.java" 2059]
   [com.sun.glass.utils.NativeLibLoader
    loadLibraryInternal
    "NativeLibLoader.java"
    170]
   [com.sun.glass.utils.NativeLibLoader
    loadLibrary
    "NativeLibLoader.java"
    58]
   [com.sun.glass.ui.gtk.GtkApplication
    lambda$new$5
    "GtkApplication.java"
    173]
   [java.security.AccessController
    doPrivileged
    "AccessController.java"
    319]
   [com.sun.glass.ui.gtk.GtkApplication
    <init>
    "GtkApplication.java"
    162]
   [com.sun.glass.ui.gtk.GtkPlatformFactory
    createApplication
    "GtkPlatformFactory.java"
    40]
   [com.sun.glass.ui.Application run "Application.java" 146]
   [com.sun.javafx.tk.quantum.QuantumToolkit
    startup
    "QuantumToolkit.java"
    290]
   [com.sun.javafx.application.PlatformImpl
    startup
    "PlatformImpl.java"
    292]
   [javafx.application.Platform startup "Platform.java" 113]
   [main$_main invokeStatic "main.clj" 8]
   [main$_main invoke "main.clj" 7]
   [clojure.lang.AFn applyToHelper "AFn.java" 152]
   [clojure.lang.AFn applyTo "AFn.java" 144]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause
  "no glassgtk3 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib"}}

@jpmonettas
Copy link
Member

Yeah, so it isn't related to FlowStorm, it can't run any javafx program because it can't find gassgtk3.

It says it is searching in /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib

In my Debian system it is here /home/jmonetta/.openjfx/cache/21.0.4-ea+1/amd64/libglassgtk3.so

You can maybe try to search for that library file (libglassgtk3.so) and if it is there somewhere, try run the little project like with this deps.edn :

{:deps {org.openjfx/javafx-controls {:mvn/version "21.0.4-ea+1"}
        org.openjfx/javafx-base {:mvn/version "21.0.4-ea+1"}
        org.openjfx/javafx-graphics {:mvn/version "21.0.4-ea+1"}}
 :aliases {:javafx {:jvm-opts ["-Djava.library.path=/usr/.../glass-folder/"]}}}

Then you can run with clj -M:javafx -m main and the JVM should also look for libraries there.

But all this is quite hacky, there is probably a better way of running javafx application in Nix.

@jpmonettas
Copy link
Member

@bennyandresen
Copy link

bennyandresen commented Jan 17, 2025

I don't know of a clean way to solve this issue, but what you can do is basically set LD_LIBRARY_PATH (which also affects the system property java.library.path) to the required libraries in a devshell.

{
  description = "example flake for openjfx compatibility";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
    flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
  };

  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [ "x86_64-linux" ];
      perSystem = { pkgs, config, ... }:
        let
          libraries = with pkgs; [
            at-spi2-atk
            cairo
            gdk-pixbuf
            glib
            gtk3
            pango
            xorg.libXtst
            libGL
            xorg.libX11
            xorg.libXxf86vm
          ];
          libraryPath = pkgs.lib.makeLibraryPath libraries;
        in {
          devShells.default = pkgs.mkShell {
            buildInputs = libraries;
            shellHook = ''
              export LD_LIBRARY_PATH=${libraryPath}:$LD_LIBRARY_PATH
            '';
          };
        };
    };
}

just run nix develop and from within that environment openjfx programs start. Works for me with flow-storm-dbg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants