I have a JavaFX based CLI jar applications used for upgrading the firmware image in to the microchip board. I created a docker image and its not running. But when the jar file application running with standalone app its running.
anees@user-X542UQR:~/BSU/CLI$ docker run -it hello_app1
Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:59)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 14 more
This is the error for the docker run
Regards
ANees
This tells you that the JAR file is not where the java command is looking for it. Or:
…this may indicate that the JAR in the image is different from the JAR you used without Docker?
To debug, please show us the Dockerfile you used to create the image. And if you specified a custom ENTRYPOINT in the Dockerfile, then also the contents of your script that runs the java command.
Also, please give us the exact docker run command you use.
Did you actualy try to run the jar from the commandline on the host or just from the IDE (where everything is configured in the project settings and your run profile)?
If I remember right, starting with java 11, JavaFX is extracted in a seperate JavaFX SDK. Did you include the SDK in your image and need to add it to your classpath.
Even though you happen to have the problem within a docker container, it is rather a java problem and not a docker problem.
Also: a docker container is not able to run desktop applications by default. On a linux system you can mount the x11 demon socket into the container and use it to render the desktop application on the xserver of the host… make sure to add -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -h $HOSTNAME -v $HOME/.Xauthority:/home/$USER/.Xauthority in front of the image name for that. This will not work with Docker Desktop for Windows - and I have no idea if it does with Desktop Desktop for Mac.
I hereby attached all the details with you. Please help me to fix this issue as soon as possible. Also please let me know which version of java jdk is used for this?
Dockerfile - Dockerfile
Eclipse_JavaFX_Running_Screenshot.png - JavaFX build and running using Eclipse IDE- We used the JDK as jdk1.8.0_311 in the eclipse
JavaFX_CLI_jdk_1_8_0_311_running.png - We used the jdk1.8.0_311 java binary for running in the CLI the build jar file using eclipse.
JavaFX_CLI_zulu8.40.0.25-ca-fx-jre8.0.222-linux_x64 - We used this jre copied from the Java Unified Host controller application provided by Microchip and ran the build Jar file using eclipse.
JavaFX_Docker_Buil_Run_Error.png - Docker is built successfully and running those images shows an error.
Regards
Anees
(Attachment Docker_JavaFX_Document.docx is missing)
I hereby attached all the details with you. Please help me to fix this issue as soon as possible. Also please let me know which version of java jdk is used for this?
Dockerfile.txt - Dockerfile
Eclipse_JavaFX_Running_Screenshot.png - JavaFX build and running using Eclipse IDE- We used the JDK as jdk1.8.0_311 in the eclipse
JavaFX_CLI_jdk_1_8_0_311_running.png - We used the jdk1.8.0_311 java binary for running in the CLI the build jar file using eclipse.
JavaFX_CLI_zulu8.40.0.25-ca-fx-jre8.0.222-linux_x64 - We used this jre copied from the Java Unified Host controller application provided by Microchip and ran the build Jar file using eclipse.
JavaFX_Docker_Buil_Run_Error.png - Docker is built successfully and running those images shows an error.
Regards
Anees
(Attachment Docker_JavaFX_Document.docx is missing)
I hereby attached all the details with you. Please help me to fix this issue as soon as possible. Also please let me know which version of java jdk is used for this?
Dockerfile.txt - Dockerfile
Eclipse_JavaFX_Running_Screenshot.png - JavaFX build and running using Eclipse IDE- We used the JDK as jdk1.8.0_311 in the eclipse
JavaFX_CLI_jdk_1_8_0_311_running.png - We used the jdk1.8.0_311 java binary for running in the CLI the build jar file using eclipse.
JavaFX_CLI_zulu8.40.0.25-ca-fx-jre8.0.222-linux_x64 - We used this jre copied from the Java Unified Host controller application provided by Microchip and ran the build Jar file using eclipse.
JavaFX_Docker_Buil_Run_Error.png - Docker is built successfully and running those images shows an error.
I hereby attached all the details with you. Please help me to fix this issue as soon as possible. Also please let me know which version of java jdk is used for this?
Dockerfile.txt - Dockerfile
Eclipse_JavaFX_Running_Screenshot.png - JavaFX build and running using Eclipse IDE- We used the JDK as jdk1.8.0_311 in the eclipse
JavaFX_CLI_jdk_1_8_0_311_running.png - We used the jdk1.8.0_311 java binary for running in the CLI the build jar file using eclipse.
JavaFX_CLI_zulu8.40.0.25-ca-fx-jre8.0.222-linux_x64 - We used this jre copied from the Java Unified Host controller application provided by Microchip and ran the build Jar file using eclipse.
JavaFX_Docker_Buil_Run_Error.png - Docker is built successfully and running those images shows an error.
Please try to not answer the discussions with mails that have the same content.
I am quite puzzled why you use different java variations on the host and a diferent (your Dockfile says amazoncorretto:8) variation inside the container.
Since you know that it’s running with one of the variations you have on your host, it makes most sense to use the COPY instruction to copy one of those variations into your image and use it to execute the command.
The problem, that docker will not support Desktop applications out of the box is not addressed by your commands. I gave an example of how the docker run command needs to be extended to make the container render a desktop application on the hosts xserver.
I would avoid to use the /tmp folder to store your data in the image.
I tried a couple of Java JDK versions and all the versions have the same issues. The one and only java that is working through CLI [not docker] is mentioned in my previous mail. Can you please tell me how I can use the Java folder which I used in my system through CLI in docker ? I used the COPY command and copied the Java folder into the /tmp folder and used that /tmp/java in the CMD command and it’s not working. Can you please help me how can I use the Java which I am working on in my system into docker image? Also which location i used instead of /tmp folder location? I didn’t see any attachment on your side for the sample example. please check and let me know
Please try docker run -it --entrypoint sh javafx_cli ls /opt/ and see if the jdk1.8.0_311 is inside or wether the whole content of the folder is copied into /opt`
I can’t run those commands you mentioned in the mail.
anees@user-X542UQR:~/BSU/CLI$ docker run -it --entrypoint sh javafx_cli ls /opt/
sh: 0: Can’t open ls
I finally fixed those errors and still have two more errors. Please help me resolve those errors.
anees@user-X542UQR:~/BSU/CLI$ sudo docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -it javafx_cli
[sudo] password for anees:
Number of ips = 1
10.42.0.236
libGL error: MESA-LOADER: failed to retrieve device information
Prism-ES2 Error : GL_VERSION (major.minor) = 1.3
(java:1): dbind-WARNING **: 18:28:48.954: Couldn’t connect to accessibility bus: Failed to connect to socket /tmp/dbus-8EdID7oYGS: Connection refused
Gtk-Message: 18:28:48.986: Failed to load module “canberra-gtk-module”
Gtk-Message: 18:28:48.988: Failed to load module “canberra-gtk-module”
Jul 19, 2022 6:28:49 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Trying to Connect: 10.42.0.236
Enter 1 times
Hex File (re)loaded…
Reading Version …
I can’t run those commands you mentioned in the mail.
anees@user-X542UQR:~/BSU/CLI$ docker run -it --entrypoint sh javafx_cli ls /opt/
sh: 0: Can’t open ls
I finally fixed those errors and still have two more errors. Please help me resolve those errors.
anees@user-X542UQR:~/BSU/CLI$ sudo docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -it javafx_cli
[sudo] password for anees:
Number of ips = 1
10.42.0.236
libGL error: MESA-LOADER: failed to retrieve device information
Prism-ES2 Error : GL_VERSION (major.minor) = 1.3
(java:1): dbind-WARNING **: 18:28:48.954: Couldn’t connect to accessibility bus: Failed to connect to socket /tmp/dbus-8EdID7oYGS: Connection refused
Gtk-Message: 18:28:48.986: Failed to load module “canberra-gtk-module”
Gtk-Message: 18:28:48.988: Failed to load module “canberra-gtk-module”
Jul 19, 2022 6:28:49 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Trying to Connect: 10.42.0.236
Enter 1 times
Hex File (re)loaded…
Reading Version …
I am surprised that it doesn’t work. Though, the error message “/opt/jdk1.8.0_311/bin/java: no such file or directory: unknown.” made me think there is a problem with the path, the command should only provide evidence about if a path problem exists. Though, since you doesn’t seem to have the path problem anymore, the command became irrelevant.
When it commes to running your javafx application inside a container. I shared what I know about running desktop applications in containers. As I don’t believe and don’t use desktop applications in containers, I can’t realy help you with the error messages you get now. It looks like javafx expects some library to be existing that don’t exist and some requirements opengl. You’ll have to wait till someone commes around that is able to make sense of it or investigate yourself.