Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java VM crashes under Mac OS X on Spring persistence layer startup

I am developing a Spring application which uses Spring Data. We are working in Eclipse Luna (4.4.0) and are using Java 8 update 20 (same problem occurs in higher versions).

When starting the application from Eclipse under Windows it works fine. Under Mac OS X the following error occurs:

2015-04-22 14:26:27.492  INFO 5363 --- [           main] o.s.j.d.DriverManagerDataSource          : Loaded JDBC driver: com.mysql.jdbc.Driver
2015-04-22 14:26:27.590  INFO 5363 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'jpaPersistenceUnit'
2015-04-22 14:26:28.715  INFO 5363 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'jpaPersistenceUnit'
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fff890330dd, pid=5363, tid=30215
#
# JRE version: Java(TM) SE Runtime Environment (8.0_20-b26) (build 1.8.0_20-b26)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.20-b23 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libobjc.A.dylib+0x10dd]  objc_msgSend+0x1d

As you can see the error occurs when initializing the database connection to mysql. That database is running.

Any general ideas how to fix this? I know it is a stretch to ask it like this, but please let me know if more information could help. Maybe there are well known situations in which this can occur.

UPDATE:

contents of error log:

Pastebin: hs_err_pid5336.log

like image 862
titusn Avatar asked Nov 01 '22 06:11

titusn


1 Answers

I had this exact problem occur when trying to embed a library with a JavaFX dependency in a headless environment. Initially I had built a JavaFX boot wrapper using a Swing container. This setup caused the JVM to crash with the mentioned crash dump.

I found this solution: https://stackoverflow.com/a/25969138/2633009. The idea is to remove the Swing wrapper and launch the JavaFX environment using the following code:

import javafx.application.Application;
import javafx.stage.Stage;

public class JavaFXInitializer extends Application {

    private static Object barrier = new Object();

    @Override
    public void start(final Stage primaryStage) throws Exception {
        synchronized (barrier) {
            barrier.notify();
        }
    }

    public static void initialize() throws InterruptedException {
        Thread t = new Thread("JavaFX Init Thread") {
            @Override
            public void run() {
                Application.launch(JavaFXInitializer.class, new String[0]);
            }
        };
        t.setDaemon(true);
        t.start();
        synchronized (barrier) {
            barrier.wait();
        }
    }
}

Which is then called in the main application at boot time using:

try {
    JavaFXInitializer.initialize();
} catch (InterruptedException e) {
    // Failed to initialise JavaFX
    e.printStackTrace();
}

My Spring application now runs smooth on both OSX and Windows.

like image 165
Stern Avatar answered Nov 03 '22 01:11

Stern