beryx / badass-jlink-plugin

Create a custom runtime image of your modular application
https://badass-jlink-plugin.beryx.org
Apache License 2.0
387 stars 27 forks source link

Problem with Hibernate #71

Closed OssNass closed 5 years ago

OssNass commented 5 years ago

I'm trying to add Hibernate-core to my application but I keep getting that java.activation module not found despite the fact the file javax.activation is in the class path and is referenced in module-info.java file

My gradle file:

plugins {
    id 'java'
    id 'org.openjfx.javafxplugin' version '0.0.7'
    id 'org.beryx.jlink' version '2.11.1'
    id 'application'
    id 'idea'
}

group 'com.ocomp'
version '1.0-SNAPSHOT'

sourceCompatibility = 12

javafx {
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml

    compile group: 'org.ocomp', name: 'simplefx-11', version: '0.1'

// https://mvnrepository.com/artifact/org.hsqldb/hsqldb
    compile group: 'org.hsqldb', name: 'hsqldb', version: '2.5.0'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
    compile group: 'org.hibernate', name: 'hibernate-core', version: '5.4.3.Final'
// https://mvnrepository.com/artifact/javax.activation/javax.activation-api
    compile group: 'javax.activation', name: 'javax.activation-api', version: '1.2.0'

}

ext {
    moduleName = 'com.ocomp.voroniy'
    moduleLaunchPoint = 'com.ocomp.voroniy.app.Main'
}

jlink() {
    def javaHome = System.properties.'java.home'
    options = ['--strip-debug', '--compress', '2',
               '--no-header-files', '--no-man-pages',
    ]
    launcher {
        name = 'voroniy'
    }
    mergedModule {
        requires 'java.transaction.xa';
        requires 'java.logging';
        requires 'java.compiler';
        requires 'org.jvnet.staxex';
        requires 'jdk.attach';
        requires 'java.datatransfer';
        requires 'java.sql';
        requires 'java.naming';
        requires 'com.sun.xml.txw2';
        requires 'java.desktop';
        requires 'java.rmi';
        requires 'jdk.jdi';
        requires 'com.sun.istack.runtime';
        requires 'java.instrument';
        requires 'java.xml';
        requires 'com.sun.xml.fastinfoset';
        requires 'java.management';
    }
}

mainClassName="${moduleName}/${moduleLaunchPoint}"`

My module-info.java

module com.ocomp.voroniy {
    exports com.ocomp.voroniy.app;

    requires org.ocomp.simplefx;

    requires java.activation;
    requires org.hibernate.orm.core;

    requires javafx.base;
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.graphics;
}

The output of suggestMergedModuleInfo is

Cannot derive uses clause from service loader invocation in: javax/xml/bind/ServiceLoaderUtil.firstByServiceLoader().
Cannot derive uses clause from service loader invocation in: org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.loadJavaServices().
mergedModule {
    requires 'java.transaction.xa';
    requires 'java.logging';
    requires 'java.compiler';
    requires 'org.jvnet.staxex';
    requires 'jdk.attach';
    requires 'java.datatransfer';
    requires 'java.sql';
    requires 'java.naming';
    requires 'com.sun.xml.txw2';
    requires 'java.desktop';
    requires 'java.rmi';
    requires 'jdk.jdi';
    requires 'com.sun.istack.runtime';
    requires 'java.instrument';
    requires 'java.xml';
    requires 'com.sun.xml.fastinfoset';
    requires 'java.management';
    uses 'javax.persistence.spi.PersistenceProvider';
    uses 'org.jboss.logging.LoggerProvider';
    provides 'javax.persistence.spi.PersistenceProvider' with 'org.hibernate.jpa.HibernatePersistenceProvider';
    provides 'javax.xml.bind.JAXBContext' with 'com.sun.xml.bind.v2.ContextFactory';
    provides 'java.sql.Driver' with 'org.hsqldb.jdbc.JDBCDriver';
}

The output of jlink error: module not found: java.activation

siordache commented 5 years ago

Replace:

compile group: 'javax.activation', name: 'javax.activation-api', version: '1.2.0'

with:

compile group: 'com.sun.activation', name: 'javax.activation', version: '1.2.0'
OssNass commented 5 years ago

Didn't work, Now the module says Module 'com.ocomp.voroniy' reads 'javax.activation' from both 'java.activation' and 'java.activation'

When importing hibernate, java.activation is imported automatically

OssNass commented 5 years ago

Going from Hibernate 5.4 to 6.0.0.Alpha2 fixed the problem