fvarrui / JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
GNU General Public License v3.0
1.07k stars 134 forks source link

1.7.6 unexpected question #429

Closed NewStorm-0 closed 2 months ago

NewStorm-0 commented 2 months ago

I'm submitting a…

Short description of the issue/suggestion: When I used the version 1.7.5 in my peoject, everything is normal. After I changed the version from 1.7.5 to 1.7.6, the packaged program runs without errors but doesn't show anything. I don't know what happened at all.

Please tell us about your environment:

Other information (e.g. related issues, suggestions how to fix, links for us to have context) My configuration information about javapackager:

<plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>1.7.5</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <mainClass>
                                com.chaldea.visualparsing.Main
                            </mainClass>
                            <platform>windows</platform>
                            <bundleJre>true</bundleJre>
                            <generateInstaller>false</generateInstaller>
                            <copyDependencies>true</copyDependencies>
                            <winConfig>
                                <headerType>gui</headerType>
<!--                                <headerType>console</headerType>-->
                            </winConfig>
                            <administratorRequired>true</administratorRequired>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
fvarrui commented 2 months ago

Hi @NewStorm-0! Could you try setting winConfig.headerType=console and run your EXE from terminal? Maybe so we can have an idea about what's happening.

Or could provide a sample project to reproduce your issue?

Thanks

NewStorm-0 commented 2 months ago

Hi @NewStorm-0! Could you try setting winConfig.headerType=console and run your EXE from terminal? Maybe so we can have an idea about what's happening.

Or could provide a sample project to reproduce your issue?

Thanks

I have tried to set winConfig.headerType=console and run executable file from windows terminal, but there is still nothing to show. When I ran it, there was only a black window that flashed past, and there was nothing in it. Later I will try to provide a example to reproduce it.

Here is a picture of the terminal.

2024-09-13_130138
NewStorm-0 commented 2 months ago

Hi, @fvarrui . I was wrong. Error message is reported in terminal mode. But the window disappeared so fast that I couldn't see the information. Do you have any idea? Now, it is a little difficult for me to make a sample project.

NewStorm-0 commented 2 months ago

Hi @NewStorm-0! Could you try setting winConfig.headerType=console and run your EXE from terminal? Maybe so we can have an idea about what's happening.

Or could provide a sample project to reproduce your issue?

Thanks

I successfully made a sample project and I found the error is caused by logback. visual-parsing-mwe.zip

NewStorm-0 commented 2 months ago

Hi @NewStorm-0! Could you try setting winConfig.headerType=console and run your EXE from terminal? Maybe so we can have an idea about what's happening.

Or could provide a sample project to reproduce your issue?

Thanks

I successfully made a sample project and I found the error is caused by logback. visual-parsing-mwe.zip

Hi @fvarrui, could you run this sample project?

fvarrui commented 2 months ago

Hi @fvarrui, could you run this sample project?

Sorry, I'm looking right now. I'll tell you something ASAP.

fvarrui commented 2 months ago

image

Ok, let me explain.

Right now JP 1.7.6(-) is not able to perfectly determine the modules that the JRE generated for your application needs to contain.

How did I know that?

  1. Set administratorRequired=false.
  2. Build your app again.
  3. Finally, run from console and it printed this error:
    C:\Users\fvarrui\Downloads\visual-parsing-mwe>target\visualParsing\visualParsing.exe
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/naming/NamingException
        at ch.qos.logback.classic.joran.ModelClassToModelHandlerLinker.link(ModelClassToModelHandlerLinker.java:66)
        at ch.qos.logback.classic.joran.JoranConfigurator.addModelHandlerAssociations(JoranConfigurator.java:88)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.processModel(GenericXMLConfigurator.java:204)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:170)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:122)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:65)
        at ch.qos.logback.classic.util.DefaultJoranConfigurator.configureByResource(DefaultJoranConfigurator.java:68)
        at ch.qos.logback.classic.util.DefaultJoranConfigurator.configure(DefaultJoranConfigurator.java:35)
        at ch.qos.logback.classic.util.ContextInitializer.invokeConfigure(ContextInitializer.java:128)
        at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:103)
        at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:66)
        at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:52)
        at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41)
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:195)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:182)
        at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:490)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:476)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:425)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:451)
        at com.chaldea.visualparsing.VisualApplication.<clinit>(VisualApplication.java:14)
        at com.chaldea.visualparsing.Main.main(Main.java:10)
    Caused by: java.lang.ClassNotFoundException: javax.naming.NamingException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 21 more

Then, I list all JDK modules to find out what's the missing one:

C:\Users\fvarrui\Downloads\visual-parsing-mwe>java --list-modules
java.base@21.0.4
java.compiler@21.0.4
java.datatransfer@21.0.4
java.desktop@21.0.4
java.instrument@21.0.4
java.logging@21.0.4
java.management@21.0.4
java.management.rmi@21.0.4
java.naming@21.0.4     <----------------------- THE MISSING ONE!
java.net.http@21.0.4
java.prefs@21.0.4
java.rmi@21.0.4
java.scripting@21.0.4
java.se@21.0.4
java.security.jgss@21.0.4
java.security.sasl@21.0.4
java.smartcardio@21.0.4
java.sql@21.0.4
java.sql.rowset@21.0.4
java.transaction.xa@21.0.4
java.xml@21.0.4
java.xml.crypto@21.0.4
jdk.accessibility@21.0.4
jdk.attach@21.0.4
jdk.charsets@21.0.4
jdk.compiler@21.0.4
jdk.crypto.cryptoki@21.0.4
jdk.crypto.ec@21.0.4
jdk.crypto.mscapi@21.0.4
jdk.dynalink@21.0.4
jdk.editpad@21.0.4
jdk.hotspot.agent@21.0.4
jdk.httpserver@21.0.4
jdk.incubator.vector@21.0.4
jdk.internal.ed@21.0.4
jdk.internal.jvmstat@21.0.4
jdk.internal.le@21.0.4
jdk.internal.opt@21.0.4
jdk.internal.vm.ci@21.0.4
jdk.internal.vm.compiler@21.0.4
jdk.internal.vm.compiler.management@21.0.4
jdk.jartool@21.0.4
jdk.javadoc@21.0.4
jdk.jcmd@21.0.4
jdk.jconsole@21.0.4
jdk.jdeps@21.0.4
jdk.jdi@21.0.4
jdk.jdwp.agent@21.0.4
jdk.jfr@21.0.4
jdk.jlink@21.0.4
jdk.jpackage@21.0.4
jdk.jshell@21.0.4
jdk.jsobject@21.0.4
jdk.jstatd@21.0.4
jdk.localedata@21.0.4
jdk.management@21.0.4
jdk.management.agent@21.0.4
jdk.management.jfr@21.0.4
jdk.naming.dns@21.0.4
jdk.naming.rmi@21.0.4
jdk.net@21.0.4
jdk.nio.mapmode@21.0.4
jdk.random@21.0.4
jdk.sctp@21.0.4
jdk.security.auth@21.0.4
jdk.security.jgss@21.0.4
jdk.unsupported@21.0.4
jdk.unsupported.desktop@21.0.4
jdk.xml.dom@21.0.4
jdk.zipfs@21.0.4

And add this module as an additional module for JRE generation:

<additionalModules>
    <additionalModule>java.naming</additionalModule>
</additionalModules>

Now, your bundled JRE contains java.naming module, and it runs without errors. I hope it helps!

There's a fix pending to be released in 1.7.7 which could fix this missing modules issue.

NewStorm-0 commented 2 months ago

image

Ok, let me explain.

Right now JP 1.7.6(-) is not able to perfectly determine the modules that the JRE generated for your application needs to contain.

How did I know that?

  1. Set administratorRequired=false.
  2. Build your app again.
  3. Finally, run from console and it printed this error:
    C:\Users\fvarrui\Downloads\visual-parsing-mwe>target\visualParsing\visualParsing.exe
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/naming/NamingException
        at ch.qos.logback.classic.joran.ModelClassToModelHandlerLinker.link(ModelClassToModelHandlerLinker.java:66)
        at ch.qos.logback.classic.joran.JoranConfigurator.addModelHandlerAssociations(JoranConfigurator.java:88)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.processModel(GenericXMLConfigurator.java:204)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:170)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:122)
        at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:65)
        at ch.qos.logback.classic.util.DefaultJoranConfigurator.configureByResource(DefaultJoranConfigurator.java:68)
        at ch.qos.logback.classic.util.DefaultJoranConfigurator.configure(DefaultJoranConfigurator.java:35)
        at ch.qos.logback.classic.util.ContextInitializer.invokeConfigure(ContextInitializer.java:128)
        at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:103)
        at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:66)
        at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:52)
        at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41)
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:195)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:182)
        at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:490)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:476)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:425)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:451)
        at com.chaldea.visualparsing.VisualApplication.<clinit>(VisualApplication.java:14)
        at com.chaldea.visualparsing.Main.main(Main.java:10)
    Caused by: java.lang.ClassNotFoundException: javax.naming.NamingException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 21 more

Then, I list all JDK modules to find out what's the missing one:

C:\Users\fvarrui\Downloads\visual-parsing-mwe>java --list-modules
java.base@21.0.4
java.compiler@21.0.4
java.datatransfer@21.0.4
java.desktop@21.0.4
java.instrument@21.0.4
java.logging@21.0.4
java.management@21.0.4
java.management.rmi@21.0.4
java.naming@21.0.4     <----------------------- THE MISSING ONE!
java.net.http@21.0.4
java.prefs@21.0.4
java.rmi@21.0.4
java.scripting@21.0.4
java.se@21.0.4
java.security.jgss@21.0.4
java.security.sasl@21.0.4
java.smartcardio@21.0.4
java.sql@21.0.4
java.sql.rowset@21.0.4
java.transaction.xa@21.0.4
java.xml@21.0.4
java.xml.crypto@21.0.4
jdk.accessibility@21.0.4
jdk.attach@21.0.4
jdk.charsets@21.0.4
jdk.compiler@21.0.4
jdk.crypto.cryptoki@21.0.4
jdk.crypto.ec@21.0.4
jdk.crypto.mscapi@21.0.4
jdk.dynalink@21.0.4
jdk.editpad@21.0.4
jdk.hotspot.agent@21.0.4
jdk.httpserver@21.0.4
jdk.incubator.vector@21.0.4
jdk.internal.ed@21.0.4
jdk.internal.jvmstat@21.0.4
jdk.internal.le@21.0.4
jdk.internal.opt@21.0.4
jdk.internal.vm.ci@21.0.4
jdk.internal.vm.compiler@21.0.4
jdk.internal.vm.compiler.management@21.0.4
jdk.jartool@21.0.4
jdk.javadoc@21.0.4
jdk.jcmd@21.0.4
jdk.jconsole@21.0.4
jdk.jdeps@21.0.4
jdk.jdi@21.0.4
jdk.jdwp.agent@21.0.4
jdk.jfr@21.0.4
jdk.jlink@21.0.4
jdk.jpackage@21.0.4
jdk.jshell@21.0.4
jdk.jsobject@21.0.4
jdk.jstatd@21.0.4
jdk.localedata@21.0.4
jdk.management@21.0.4
jdk.management.agent@21.0.4
jdk.management.jfr@21.0.4
jdk.naming.dns@21.0.4
jdk.naming.rmi@21.0.4
jdk.net@21.0.4
jdk.nio.mapmode@21.0.4
jdk.random@21.0.4
jdk.sctp@21.0.4
jdk.security.auth@21.0.4
jdk.security.jgss@21.0.4
jdk.unsupported@21.0.4
jdk.unsupported.desktop@21.0.4
jdk.xml.dom@21.0.4
jdk.zipfs@21.0.4

And add this module as an additional module for JRE generation:

<additionalModules>
    <additionalModule>java.naming</additionalModule>
</additionalModules>

Now, your bundled JRE contains java.naming module, and it runs without errors. I hope it helps!

There's a fix pending to be released in 1.7.7 which could fix this missing modules issue.

🥰Thanks. I understand all this now.