Having hibernate in the plugin jar crashes sponge without an error

When I include hibernate in my JAR, sponge crashes right after “[INFO] [Sponge]: Loading plugins…” without any error…


I’ve also tried with other Hibernate versions, same problem… When I remove it, sponge loads the plugin just fine…

What do?

“sponge crashes without any errors”? Would you mind sending a log over? We may see something that your not?

This is literally all of it:

[21:17:33 INFO] [Sponge]: Initializing Sponge...
[21:17:33 INFO] [Sponge]: De-obfuscation mappings are provided by MCP (http://www.modcoderpack.com)
[21:17:33 INFO] [mixin]: SpongePowered MIXIN Subsystem Version=0.8 Source=file:/C:/Users/jake/Desktop/server/spongevanilla-1.12.2-7.1.9.jar Service=LaunchWrapper Env=UNKNOWN
[21:17:34 INFO] [mixin]: FML platform manager could not load class cpw.mods.fml.relauncher.CoreModManager. Proceeding without FML support.
[21:17:34 INFO] [mixin]: Compatibility level set to JAVA_8
[21:17:34 INFO] [Sponge]: Searching for plugins...

This is where sponge just stops…

So after the “loading plugins” bit? Does the server close (so it can accept another command - close the terminal - “,press any key to exit” (depending on your os)) or does it just freeze?

The server exits completely, doesn’t freeze

When does your plugin load hibernate? Constructor? Sponge event (such as GameStartingServerEvent)?

GameStartingServerEvent, however this happens even when I don’t actually load hibernate and just have it as a dependency

Thats interesting. So just having the files in your plugin, even if they are not initiated cause this issue?

Yeah, loads just fine when I remove hibernate from the jar

Im not too sure. Ill try and replicate the issue on my pc and get down to the bottom. It maybe that using an IDE debug mode would give more info (such as the client debug mode of forge that works with sponge)

Cheers. I get the feeling it’s gonna be some super simple stupid mistake but not having any error messages really doesn’t help :smiley:

Ive never seen not having an error or something (it maybe a java option you have turned on or something (i think there is a option like --nostacktrace))

ive also never seen sponge crash there, it normally fails to load a plugin and then would skip out that plugin, but with yours its crashing the whole server.

Lastly I have never seen a plugin fail because it has extra files that don’t get interacted with inside it

Definitely don’t have that option on… But yeah, I’ve never seen something like this before

I’ve had sponge crash before when there were class files inside META-INF folder (from dependencies)
Check that folder inside the jar just in case

There were some class files in META-INF but removing them didn’t help…

I’ve just tried converting the project to Gradle and I’m getting the exact same issue with the shadow plugin…

I’ve also tried replacing hibernate with jOOQ and yet again the same problem…

Might not be the perfect way, but I successfully integrated hibernate in my plugin.

My gradlew.build:

buildscript {
    repositories {
        maven {
            name 'forge'
            url 'https://files.minecraftforge.net/maven'
        maven { url "https://jitpack.io" }

    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'

plugins {
    id 'org.spongepowered.plugin' version '0.9.0'

dependencies {
    compile 'org.spongepowered:spongeapi:7.2.0-20200130.194701-33'
    compile "org.hibernate:hibernate-core:5.4.2.Final"
    compile group: 'org.jetbrains', name: 'annotations', version: '16.0.1'

apply plugin: 'net.minecraftforge.gradle.forge'

minecraft {
    forgeVersion = '1.12.2-'
    mappings = 'stable_39'

My creation of the session factory:
Be aware to add all used entity classes to the configuration. Replace in the following example the MyEntityClassToReplace with the class u use.

private static SessionFactory sessionFactory;

 * Initializes the hibernate ORM engine
public static void initialize() {
    // Defines the connection properties
    Properties properties = new Properties();
    properties.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
    properties.setProperty(Environment.DIALECT, "org.hibernate.dialect.MySQL5Dialect");
    properties.setProperty(Environment.URL, "jdbc:mysql:MyDatabase?useSSL=false");
    properties.setProperty(Environment.USER, MyUser);
    properties.setProperty(Environment.PASS, MyPassword);
    properties.setProperty(Environment.HBM2DDL_AUTO, "update");

    // Defines the entity classes
    Configuration configuration = new Configuration();

    // Creates the session factory instance of hibernate
    sessionFactory = configuration.buildSessionFactory();

The ugly way here is that I have to additionally put the needed libraries into the mod folder aswell. I know that isn’t the best way and it might be bring some errors, but at the moment it work and I am fine with it. In the future, when I release the plugin I will try to find a better way for it.

I hope this could help you