eclipsedockerjavafxeclipse-rcpefxclipse

Fatal error when running a JavaFX GUI app inside Eclipse in a Docker container


Eclipse is working fine inside the container and its window is visible on the host (with the X11 being shared through socket).

The app is an Eclipse RCP project using JavaFX (Efxclipse and M2Eclipse). I removed all the references for the RCP below to have less complexity in the example and because it happens with really simple JavaFX apps (non-OSGI) as well - so OSGI isn't the issuer.

The following fatal error is happening when running a JavaFX GUI app inside Eclipse (inside a Docker container).

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f56bb14dd20, pid=233, tid=0x00007f567cea1700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [ld-linux-x86-64.so.2+0x9d20]
#
# Core dump written. Default location: /home/docker/test/JavaFX/login/core or core.233
#
# An error report file with more information is saved as:
# /home/docker/test/JavaFX/login/hs_err_pid233.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

The full log can be found here.

Host details:

Container details:

Code for the JavaFX app:

package application;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;


public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            Scene scene = new Scene(new BorderPane(),400,400);
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Although I had success running a simple GUI app using Swing:

package application;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Test {

    private static void createAndShowGUI() {
        JFrame frame = new JFrame("Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500, 500);
        JLabel label = new JLabel("Test");
        frame.getContentPane().add(label);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

and this lead us to some problem related to JavaFX.

Even running an exported JavaFX app (as a Jar file) on the console (outside Eclipse) it's returning the same error.

Ideas on how to solve it and have the JavaFX app running inside Eclipse in the container?

Thanks


Solution

  • The problem was related to few missing dependencies in my Ubuntu image. Without them I was not able to run JavaFX apps in a Docker container.

    Installing the following packages solved the problem:

    gtk2-engines
    libswt-gtk-3-java
    libxslt1.1
    libxtst6
    libxxf86vm1
    

    I tried to install only one or two of them (a sort of combination) in an attempt to find out which one exactly is needed but it turned out to be time consuming so I'm installing all of them - for now.

    I found the solution on this Dockerfile when searching for examples on Github. Thanks Patrick Martin.