Open zshamrock opened 6 years ago
Also looks like Web Browser API/feature is not supported by the Amazon Corretto:
java.lang.NullPointerException
at javafx.application.HostServices.showDocument(HostServices.java:127)
at com.akazlou.dynoman.view.MainView$root$1$1$1$4$1.invoke(MainView.kt:39)
at com.akazlou.dynoman.view.MainView$root$1$1$1$4$1.invoke(MainView.kt:9)
at tornadofx.ControlsKt$action$4.handle(Controls.kt:428)
at tornadofx.ControlsKt$action$4.handle(Controls.kt)
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.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
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:198)
at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$6(ContextMenuContent.java:1358)
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.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:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$10(GtkApplication.java:245)
at java.lang.Thread.run(Thread.java:748)
Initial idea was to use Amazon Corretto JDK 8 as the base image (as it contains JavaFX) and Jib (so no need for Dockerfile), although when tried it missing libX11-6.so library, and so the app can't be run. Maybe instead build my own Dockerfile using another base image, and instead just use Amazon Corretto for run, ex.: https://github.com/corretto/corretto-8-docker/issues/1#issuecomment-497499862.
Or explore other Open JDK distributions: BellSoft Liberica https://hub.docker.com/r/bellsoft/liberica-openjdk-alpine and Zulu https://hub.docker.com/r/azul/zulu-openjdk-alpine whether they contain JavaFX and based on more appropriate base image (it feels like I have to write my Dockerfile anyway).
$ docker run --net host -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/root/.Xauthority -e DISPLAY=unix$DISPLAY dynoman
checking GTK version 2
trying GTK library libgtk-x11-2.0.so.0
trying GTK library libgtk-x11-2.0.so
trying GTK library libgtk-3.so.0
trying GTK library libgtk-3.so
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.UnsupportedOperationException: Internal Error
at com.sun.glass.ui.gtk.GtkApplication.lambda$new$5(GtkApplication.java:158)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:140)
at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
at com.sun.glass.ui.Application.run(Application.java:146)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
Picked up JAVA_TOOL_OPTIONS: -Djdk.gtk.verbose=true -Djavafx.verbose=true
> Task :run
Picked up JAVA_TOOL_OPTIONS: -Djdk.gtk.verbose=true -Djavafx.verbose=true
Loaded /home/alex/.sdkman/candidates/java/8.0.222-amzn/jre/lib/ext/../amd64/libprism_es2.so from relative path
Loaded /home/alex/.sdkman/candidates/java/8.0.222-amzn/jre/lib/ext/../amd64/libprism_sw.so from relative path
JavaFX: using com.sun.javafx.tk.quantum.QuantumToolkit
Loaded /home/alex/.sdkman/candidates/java/8.0.222-amzn/jre/lib/ext/../amd64/libglass.so from relative path
checking GTK version 2
trying GTK library libgtk-x11-2.0.so.0
using GTK library version 2 set libgtk-x11-2.0.so.0
Glass GTK library to load is glassgtk2
Loaded /home/alex/.sdkman/candidates/java/8.0.222-amzn/jre/lib/ext/../amd64/libglassgtk2.so from relative path
Launching application directly
Running on Amazon.com Inc. 1.8.0_222 JVM runtime
Loaded /home/alex/.sdkman/candidates/java/8.0.222-amzn/jre/lib/ext/../amd64/libjavafx_font.so from relative path
Loaded /home/alex/.sdkman/candidates/java/8.0.222-amzn/jre/lib/ext/../amd64/libjavafx_font_freetype.so from relative path
Loaded /home/alex/.sdkman/candidates/java/8.0.222-amzn/jre/lib/ext/../amd64/libdecora_sse.so from relative path
===
Loaded /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/lib/ext/../amd64/libprism_sw.so from relative path
JavaFX: using com.sun.javafx.tk.quantum.QuantumToolkit
Loaded /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/lib/ext/../amd64/libglass.so from relative path
checking GTK version 2
trying GTK library libgtk-x11-2.0.so.0
trying GTK library libgtk-x11-2.0.so
trying GTK library libgtk-3.so.0
trying GTK library libgtk-3.so
Revisit my blog post https://akazlou.com/posts-output/2019-11-07-running-javafx-amazonlinux/, I guess this has been done/explored exactly for this purporse.
Use jib https://github.com/GoogleContainerTools/jib and Amazon Corretto Docker image as the base image https://hub.docker.com/_/amazoncorretto 8u232.
It might produce not the smallest resulting Docker image but feels like the fastest available approach to build proper Docker image.
Further improvements could be to upgrade to JDK 11, maybe build custom JRE runtime (jlink), install JavaFX modules, etc.