Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite database is not being created #3

Closed
fvarrui opened this issue Mar 23, 2022 · 91 comments
Closed

SQLite database is not being created #3

fvarrui opened this issue Mar 23, 2022 · 91 comments

Comments

@fvarrui
Copy link
Contributor

fvarrui commented Mar 23, 2022

When I run with mvn javafx:run it shows this error:

C:\Users\fvarrui\GitHub\GistFX>mvn javafx:run
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.redmondsims:GistFX >-----------------------
[INFO] Building GistFX 3.3.6
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> javafx-maven-plugin:0.0.8:run (default-cli) > process-classes @ GistFX >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ GistFX ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 89 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.0:compile (default-compile) @ GistFX ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< javafx-maven-plugin:0.0.8:run (default-cli) < process-classes @ GistFX <<<
[INFO]
[INFO]
[INFO] --- javafx-maven-plugin:0.0.8:run (default-cli) @ GistFX ---
jdbc:sqlite:C:\Users\fvarrui\AppData\Local\GistFX\SQLite\Database.sqlite
*** SQLite.createSchema ***
[SQLITE_ERROR] SQL error or missing database (incomplete input)
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (incomplete input)
        at org.sqlite.core.DB.newSQLException(DB.java:1030)
        at org.sqlite.core.DB.newSQLException(DB.java:1042)
        at org.sqlite.core.DB.throwex(DB.java:1007)
        at org.sqlite.core.NativeDB._exec_utf8(Native Method)
        at org.sqlite.core.NativeDB._exec(NativeDB.java:97)
        at org.sqlite.jdbc3.JDBC3Statement.executeUpdate(JDBC3Statement.java:102)
        at [email protected]/com.redmondsims.gistfx.data.SQLite.createSchema(SQLite.java:117)
        at [email protected]/com.redmondsims.gistfx.data.SQLite.setConnection(SQLite.java:57)
        at [email protected]/com.redmondsims.gistfx.data.Action.setDatabaseConnection(Action.java:52)
        at [email protected]/com.redmondsims.gistfx.Main.start(Main.java:165)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
        at java.base/java.lang.Thread.run(Thread.java:833)


The SQLite library failed to create the schema.
        Make sure your Access Control Lists are permissive for the folder that GistFX executes from.

Run program from a command prompt to see the full stack trace.

Exiting...
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 101 (Exit value: 101)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:567)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:434)
    at org.openjfx.JavaFXRunMojo.execute (JavaFXRunMojo.java:105)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
org.apache.commons.exec.ExecuteException: Process exited with an error: 101 (Exit value: 101)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
        at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:567)
        at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:434)
        at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:105)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  20.760 s
[INFO] Finished at: 2022-03-23T23:46:20Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.8:run (default-cli) on project GistFX: Error: Command execution failed. Process exited with an error: 101 (Exit value: 101) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

and also shows this:

image

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 23, 2022

When is created the SQLite database (C:\Users\fvarrui\AppData\Local\GistFX\SQLite\Database.sqlite) in your code? When does it try to connect to a non existing database?

@EasyG0ing1
Copy link
Contributor

@fvarrui Curious, what happens if you run the EXE as Admin?

@EasyG0ing1
Copy link
Contributor

@fvarrui - I changed the location for Windows data file storage over to the Microsoft prescribed APPDATA folder and I pushed the change to the repository. Try that.

@EasyG0ing1
Copy link
Contributor

EasyG0ing1 commented Mar 24, 2022

@fvarrui - I GOT IT WORKING! ... I'm so happy!

I pushed the working version to the repository ... next up - MacOS installer ☺

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 25, 2022

Hi @EasyG0ing1!
I've tried to build last version and I'm getting an error:

[INFO]     Bundling JRE ... with C:\Program Files\Eclipse Adoptium\jdk-17.0.1.12-hotspot
[INFO]         Creating customized JRE ...
[INFO]         Getting required modules ...
[INFO]             Executing command: cmd.exe /s /c ""C:\Program Files\Eclipse Adoptium\jdk-17.0.1.12-hotspot\bin\jdeps" -q --multi-release 17 --ignore-missing-deps --print-module-deps C:\Users\fvarrui\GistFX\target\GistFX\libs\*.jar C:\Users\fvarrui\GistFX\target\GistFX-3.3.6-runnable.jar"
[ERROR]             Exception in thread "main" java.lang.module.FindException: Module org.apache.commons.lang3 not found, required by com.redmondsims.gistfx
[ERROR]                 at java.base/java.lang.module.Resolver.findFail(Resolver.java:893)
[ERROR]                 at java.base/java.lang.module.Resolver.resolve(Resolver.java:192)
[ERROR]                 at java.base/java.lang.module.Resolver.resolve(Resolver.java:141)
[ERROR]                 at java.base/java.lang.module.Configuration.resolve(Configuration.java:421)
[ERROR]                 at java.base/java.lang.module.Configuration.resolve(Configuration.java:255)
[ERROR]                 at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:564)
[ERROR]                 at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:603)
[ERROR]                 at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:557)
[ERROR]                 at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:533)
[ERROR]                 at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.394 s
[INFO] Finished at: 2022-03-25T11:21:53Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.github.fvarrui:javapackager:1.6.5:package (package-for-windows) on project GistFX: Command execution failed: C:\Program Files\Eclipse Adoptium\jdk-17.0.1.12-hotspot\bin\jdeps -q --multi-release 17 --ignore-missing-deps --print-module-deps [Ljava.lang.String;@34e7b058 C:\Users\fvarrui\GistFX\target\GistFX\libs\*.jar C:\Users\fvarrui\GistFX\target\GistFX-3.3.6-runnable.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Sometimes jdeps run into problems when is trying to find which core modules are needed to generate a customized JRE. I fixed changing customizedJre to false, and the build process finished without problems.

                <configuration>
                    <mainClass>${exec.mainClass}</mainClass>
                    <bundleJre>true</bundleJre>
                    <customizedJre>false</customizedJre>
                    <generateInstaller>true</generateInstaller>
                    <administratorRequired>false</administratorRequired>
                    <!--
                    <jdkPath>/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home</jdkPath>
                    -->
                </configuration>

I'm on Windows.

Have you experienced this problem too?

Then, when I try to run your app it stops due to the same error as I reported before (maybe I'm missing something or doing something wrong):

C:\Users\fvarrui\GistFX>target\GistFX\GistFX.exe
*** SQLite.createSchema ***
[SQLITE_ERROR] SQL error or missing database (incomplete input)
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (incomplete input)
        at [email protected]/org.sqlite.core.DB.newSQLException(DB.java:1030)
        at [email protected]/org.sqlite.core.DB.newSQLException(DB.java:1042)
        at [email protected]/org.sqlite.core.DB.throwex(DB.java:1007)
        at [email protected]/org.sqlite.core.NativeDB._exec_utf8(Native Method)
        at [email protected]/org.sqlite.core.NativeDB._exec(NativeDB.java:97)
        at [email protected]/org.sqlite.jdbc3.JDBC3Statement.executeUpdate(JDBC3Statement.java:102)
        at com.redmondsims.gistfx.data.SQLite.createSchema(SQLite.java:116)
        at com.redmondsims.gistfx.data.SQLite.setConnection(SQLite.java:56)
        at com.redmondsims.gistfx.data.Action.setDatabaseConnection(Action.java:52)
        at com.redmondsims.gistfx.Main.start(Main.java:166)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
        at java.base/java.lang.Thread.run(Unknown Source)


The SQLite library failed to create the schema.
        Make sure your Access Control Lists are permissive for the folder that GistFX executes from.

Run program from a command prompt to see the full stack trace.

Exiting...

@EasyG0ing1
Copy link
Contributor

@fvarrui The version I just now pushed, I literally just copied the project folder over to windows then from a CMD prompt, after changing into the project directory, I ran mvn clean package and it ran fine and the exe ran fine as well.

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

Could it be because the database file already exists on your system? So, there's no need to create a new one, and in my case, as it doesn't exist, fails when creating this file

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

May you publish your Setup installer in the releases section, please?

@EasyG0ing1
Copy link
Contributor

EasyG0ing1 commented Mar 28, 2022

@fvarrui - no, the database file doesn't exist because I copy the installer off to a network drive, then I revert my virtual machine to a snapshot that I took long before I even started trying to run it on Windows and it still works.

Have you tried running it as Admin?

Also, whats the build switch that makes the Windows exe not launch a CMD window that it leaves running in the background?

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

Hi @EasyG0ing1!
I've getting a new error running with my user and as Admin:

C:\Users\fvarrui\GistFX\target\GistFX>GistFX.exe
[SQLITE_ERROR] SQL error or missing database (no such table: Gists)
        com.redmondsims.gistfx.data.SQLite.hasData(SQLite.java:366)
        com.redmondsims.gistfx.data.SQLite.gistsHasData(SQLite.java:355)
        com.redmondsims.gistfx.data.SQLite.hasData(SQLite.java:350)
        com.redmondsims.gistfx.data.SQLite.setConnection(SQLite.java:68)
        com.redmondsims.gistfx.data.Action.setDatabaseConnection(Action.java:53)
        com.redmondsims.gistfx.Main.start(Main.java:94)

It seems that it can't find the Gists table in the database.

@EasyG0ing1
Copy link
Contributor

@fvarrui - I published the installer

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

It's creating this directory structure:

C:\Users\fvarrui\AppData\Roaming\GistFX>tree /f
Listado de rutas de carpetas
El número de serie del volumen es E4F9-DB0F
C:.
├───HelpFiles
│   │   Logo.png
│   │
│   ├───General
│   │       1.png
│   │       2.png
│   │
│   └───HowToToken
│           1.png
│           2.png
│           3.png
│           4.png
│           5.png
│           6.png
│           7.png
│
├───Icons
│   └───Tree
│           ConflictFlag.png
│           DirtyFlag.png
│           File1.png
│           File2.png
│           Folder.png
│
└───SQLite
        Database.sqlite

but Database.sqlite is empty.

image

Ok ... I'm going to try with your installer and tell you something in a moment.

@EasyG0ing1
Copy link
Contributor

EasyG0ing1 commented Mar 28, 2022

@fvarrui - Try deleting this folder C:\Users\Username\AppData\Roaming\GistFX

Then re-run the program and see what happens

And make sure you have an APPDATA environment variable

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

@fvarrui - Try deleting this folder C:\Users\Username\AppData\Roaming\GistFX

Yes, done.

Then re-run the program and see what happens

Ok, I'm gonna tell you something right now.

And make sure you have an APPDATA environment variable

C:\Users\fvarrui\GistFX\target\GistFX>echo %APPDATA%
C:\Users\fvarrui\AppData\Roaming

@EasyG0ing1
Copy link
Contributor

@fvarrui - ok that looks right

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

Installed:

image

And running fine 👏 👏 👏

image

And the database is well created (not empty, at least):

image

Great work!! ... I'm not sure what I'm doing wrong when building your app, but I'm happy because now it's working fine

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

Try to change headerType property to gui, so it doesn't open a console, and add icons to EXE and to the installer as it's explained in JavaPackager docs. It's quite easy!

@EasyG0ing1
Copy link
Contributor

@fvarrui so mine will run but yours won't?

@EasyG0ing1
Copy link
Contributor

@fvarrui It might be because I have the luxury of installing all the tools from a fresh install of windows since I have the snapshots saved in VMWare ...

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

Well ... I'm not sure why, but the important thing is that your installer works fine

@EasyG0ing1
Copy link
Contributor

@fvarrui - Now I gotta figure out how to build a MacOS installer, then a linux installer after that.

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

If you want that anybody can build your app, include instructions in README.

This is my environment config:

C:\Users\fvarrui\GistFX\target\GistFX>mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\ProgramData\chocolatey\lib\maven\apache-maven-3.8.4
Java version: 17.0.1, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.1.12-hotspot
Default locale: es_ES, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

I don't know how it differs from your environment.

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

@fvarrui - Now I gotta figure out how to build a MacOS installer, then a linux installer after that.

Great! Don't hesitate to ask me if you have difficulties

@EasyG0ing1
Copy link
Contributor

@fvarrui

Heres my build environment

C:\Temp\GistFXTwo>mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\ProgramData\chocolatey\lib\maven\apache-maven-3.8.4
Java version: 17.0.2, vendor: Oracle Corporation, runtime: C:\Program Files\Java\javafx-sdk-17.0.2
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
'cmd' is not recognized as an internal or external command,
operable program or batch file.

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

I would venture to say that you only have to run mvn clean package but from a Mac OS system and from a Linux one ... and that's all!

@EasyG0ing1
Copy link
Contributor

@fvarrui - Well I'll need an execution setup properly under the plugin ... no?

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

@fvarrui

Heres my build environment

C:\Temp\GistFXTwo>mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\ProgramData\chocolatey\lib\maven\apache-maven-3.8.4
Java version: 17.0.2, vendor: Oracle Corporation, runtime: C:\Program Files\Java\javafx-sdk-17.0.2
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
'cmd' is not recognized as an internal or external command,
operable program or batch file.

Almost the same configuration ... maybe the problem is mine ... could you try to build your app on another system?

@EasyG0ing1
Copy link
Contributor

@fvarrui - The best I can do is another virtual machine ... OR I could use the BootCamp dual boot on my MacBook Pro.

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

@fvarrui - Well I'll need an execution setup properly under the plugin ... no?

This config should work on each system:

            <plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>1.6.5</version>
                <configuration>
                    <mainClass>${exec.mainClass}</mainClass>
                    <bundleJre>true</bundleJre>
                    <customizedJre>false</customizedJre>
                    <generateInstaller>true</generateInstaller>
                    <administratorRequired>false</administratorRequired>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <platform>auto</platform>
                            <createZipball>false</createZipball>
                            <createTarball>true</createTarball>
                            <vmArgs>
                                <vmArg>--module-path=libs</vmArg>
                                <vmArg>--add-modules=javafx.controls,javafx.graphics</vmArg>
                            </vmArgs>
                            <winConfig>
                                <headerType>gui</headerType>
                                <generateMsi>false</generateMsi>
                            </winConfig>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

@fvarrui
Copy link
Contributor Author

fvarrui commented Mar 28, 2022

@fvarrui - The best I can do is another virtual machine ... OR I could use the BootCamp dual boot on my MacBook Pro.

I was just saying that to make sure your app can be built from any Windows

@EasyG0ing1
Copy link
Contributor

@fvarrui - Well, I managed to get it compiled and working on my dev machine, but when I tried it on my macOS virtual machine, it errored out again saying that things were compiled with a newer version of Java ... then I was looking at the Info.plist file and saw this:

   <key>JVMOptionsFile</key>
            <string>$APP_PACKAGE/Contents/Resources/GistFX.l4j.ini</string>

And that file does not exist anywhere ... do you know what that's about?

Here is the entire Info.plist file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>CFBundleGetInfoString</key>
        <string>GistFX 3.3.6</string>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>universalJavaApplicationStub</string>
        <key>CFBundleIconFile</key>
        <string>AppleDock.icns</string>
        <key>CFBundleIdentifier</key>
        <string>com.redmondsims.gistfx.Main</string>
        <key>CFBundleDisplayName</key>
        <string>GistFX</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>GistFX</string>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
        <string>3.3.6</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>3.3.6</string>
        <key>NSHumanReadableCopyright</key>
        <string>ACME</string>
        <key>NSHighResolutionCapable</key>
        <true/>
        <key>NSSupportsAutomaticGraphicsSwitching</key>
        <true/>
        <key>AdministratorRequired</key>
        <false/>
        <key>JavaX</key>
        <dict>
            <key>MainClass</key>
            <string>com.redmondsims.gistfx.Main</string>
            <key>ClassPath</key>
            <array>
                <string>Java/GistFX-3.3.6-runnable.jar</string>
            </array>
            <key>VMOptions</key>
            <array>
                <string>--module-path=Java/libs</string>
                <string>--add-modules=javafx.controls,javafx.graphics,javafx.web</string>
            </array>
            <key>WorkingDirectory</key>
            <string>$APP_PACKAGE/Contents/Resources</string>
            <key>JVMOptionsFile</key>
            <string>$APP_PACKAGE/Contents/Resources/GistFX.l4j.ini</string>
        </dict>
        <key>LSEnvironment</key>
        <dict>
            <key>JAVA_HOME</key>
            <string>Contents/PlugIns/jre/Contents/Home</string>
        </dict>
        <key>NSAppleEventsUsageDescription</key>
        <string>There was an error while launching the application. Please
			click OK to display a dialog with more information or cancel and view
			the syslog for details.</string>
    </dict>
</plist>

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 5, 2022

then I was looking at the Info.plist file and saw this:

   <key>JVMOptionsFile</key>
            <string>$APP_PACKAGE/Contents/Resources/GistFX.l4j.ini</string>

And that file does not exist anywhere ... do you know what that's about?

Hi @EasyG0ing1!
No, that has nothing to do. It's a config file with VM arguments, loaded when running, and ignored if not exists. I'm sorry I can't help you much more.

Could you try to remove module-info.java from your JAR, and add a new Launcher class next to Main class, which calls Main.main(), and make this new class the mainclass (as explained here Solution 2)? Then remove <vmargs/> and try to run it again, please!

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 5, 2022

I have to improve JavaPackager to work better with modular apps ... until then, try this, please

@EasyG0ing1
Copy link
Contributor

EasyG0ing1 commented Apr 5, 2022

@fvarrui - OK, I did that ... and I removed the <vmargs> from the pom file then re-packaged the project.

It runs fine on my dev machine without any problems at all. But when I run it on my Mac virtual machine (that is a clean install of MacOS and has no JDK or JRE installed anywhere) ... I get this error:

Last login: Tue Apr  5 04:53:06 on ttys000
Mikes-Mac:~ michael$ /Applications/GistFX.app/Contents/MacOS/universalJavaApplicationStub ; exit;
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Print: Entry, ":0:JVMVersion", Does Not Exist
Print: Entry, ":0:JVMHomePath", Does Not Exist
283:339: execution error: System Events got an error: A resource wasn’t found. (-192)
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.

[Process completed]

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 5, 2022

Ok. Could you take a look at the syslog using Console.app? universalJavaApplicationStub logs the failures there.

@EasyG0ing1
Copy link
Contributor

@fvarrui - just to experiment, I installed jdk18 and without doing anything else (no JAVA_HOME set or anything), the app runs fine on the virtual machine now ... but I'm going to reset the snapshot and run it again then look at the logs as you suggest.

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 5, 2022

I'm not sure if the problem is with universalJavaApplicationStub launch script, but it seems that other JREs/JDKs installed on the system are interferring.

@EasyG0ing1
Copy link
Contributor

@fvarrui Well, like I said, there are no other JREs/JDKs installed on the virtual machine ... and Ive been looking in the console but nothing stands out, what am I looking for?

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 5, 2022

@fvarrui Well, like I said, there are no other JREs/JDKs installed on the virtual machine ...

Yes! You told me, sorry.

and Ive been looking in the console but nothing stands out, what am I looking for?

Any entry logged by universalJavaApplicationStub, to see if that throws any light on what's going on.

@EasyG0ing1
Copy link
Contributor

@fvarrui no ita not logging anything at all

@EasyG0ing1
Copy link
Contributor

@fvarrui the only thing I see is this error in Terminal when I launch the program:

Last login: Tue Apr  5 05:48:35 on ttys001
Mikes-Mac:~ michael$ /Applications/GistFX.app/Contents/MacOS/universalJavaApplicationStub ; exit;
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Print: Entry, ":0:JVMVersion", Does Not Exist
Print: Entry, ":0:JVMHomePath", Does Not Exist
283:339: execution error: System Events got an error: A resource wasn’t found. (-192)
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]


@EasyG0ing1
Copy link
Contributor

@fvarrui - When I double click the icon, I get this error:

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: @rpath/libjli.dylib
  Referenced from: /Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/java
  Reason: no suitable image found.  Did find:
	/Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/../lib/libjli.dylib: code signature in (/Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/../lib/libjli.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

Binary Images:
       0x108535000 -        0x108538fff +java (18 - 0) <A6E07EF4-6B41-3AC6-A452-94F801DEB828> /Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/java
       0x10b7b8000 -        0x10b853fff  dyld (852.2) <A7924265-DCEF-3515-B28E-3A8279B43E29> /usr/lib/dyld
    0x7fff2a638000 -     0x7fff2a64afff  libz.1.dylib (76) <73C471D3-07CE-307D-A531-92C5D0E4C0E9> /usr/lib/libz.1.dylib

@EasyG0ing1
Copy link
Contributor

EasyG0ing1 commented Apr 5, 2022

@fvarrui - I opened this issue - you might want to ake a look ... and I found this issue which is the exact problem I'm having.

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 6, 2022

But this other issue refers to universalJavaApplicationStub 3.1.0, and JavaPackager is using 3.2.0. It should be fixed, so, same error but different cause.

I've got a Mac Mini with MacOs 10.15 ... I'll try your project when arrive at home. Which Mac OS versions have your Mac Book and your VM?

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 6, 2022

Please, could you push your changes (in a new branch if you prefer)?

@EasyG0ing1
Copy link
Contributor

EasyG0ing1 commented Apr 6, 2022

@fvarrui - Yes, I will push the current code by the next hour or so ... and you are correct on your assertion of the issue I created on the launch script. The closed issue seemed to indicate that the problem was resolved. But clearly it's still a problem so hopefully the issue I opened will help with a fix or a plausible work-around of some kind.

He did say in the closed issue what the problem was in the script .... but on quick inspection - it's all greek to me ...

I'll post here when I posh the current code ... I gotta clean some things up in the project first.

By the way, I'm running MacOS Monteray 12.3

If you have a powerful enough PC, you can run MacOS in the free version of VMWare - Workstation (or maybe it's VMWare Player) I believe it's called for Windows - Fusion is the Mac flavor.

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 7, 2022

@fvarrui - When I double click the icon, I get this error:

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: @rpath/libjli.dylib
  Referenced from: /Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/java
  Reason: no suitable image found.  Did find:
	/Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/../lib/libjli.dylib: code signature in (/Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/../lib/libjli.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

Binary Images:
       0x108535000 -        0x108538fff +java (18 - 0) <A6E07EF4-6B41-3AC6-A452-94F801DEB828> /Applications/GistFX.app/Contents/PlugIns/jre/Contents/Home/bin/java
       0x10b7b8000 -        0x10b853fff  dyld (852.2) <A7924265-DCEF-3515-B28E-3A8279B43E29> /usr/lib/dyld
    0x7fff2a638000 -     0x7fff2a64afff  libz.1.dylib (76) <73C471D3-07CE-307D-A531-92C5D0E4C0E9> /usr/lib/libz.1.dylib

Hi @EasyG0ing1! Please, take a look to this reply. Maybe your problem could be solved with a well defined entitlements.plist file when codesigning.

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 7, 2022

If you have a powerful enough PC, you can run MacOS in the free version of VMWare - Workstation (or maybe it's VMWare Player) I believe it's called for Windows - Fusion is the Mac flavor.

Yes, I've got a MacOS 10.12.6 in a VM (I'm using VirtualBox) ... but I haven't had time to get a newer version

@EasyG0ing1
Copy link
Contributor

@fvarrui You do know that thre is a free version of VMWare for personal use? I like it much better than VirtualBox, personally.

I just pushed the latest code into the repository ... had to battle some monsters which took some time.

Mike

@EasyG0ing1
Copy link
Contributor

@fvarrui

Hi @EasyG0ing1! Please, take a look to this fvarrui/JavaPackager#185 (comment). Maybe your problem could be solved with a well defined entitlements.plist file when codesigning.

My issue isn't with code signing, it's with the app launching without being able to find the java executable when I don't have a JDK or JRE installed separately on the machine.

@EasyG0ing1
Copy link
Contributor

@fvarrui - So this is interesting ... reading that other issue more carefully, I noticed that the guy said that he was able to get it to work with packager version 1.6.2, so I tried that and sure enough, it works just fine.

Do you have any idea why?

@EasyG0ing1
Copy link
Contributor

@fvarrui - ok, the pull request you made, once I committed it, then re-packaged on MacOS, using version 1.6.6 of the packager, worked perfectly.

@EasyG0ing1
Copy link
Contributor

The current push to the repository is the working version by the way.

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 8, 2022

Great news! 😄

Sorry, I didn't have time before to explain to you in the PR why entitlements solve the problem. As Mabula (@AstroPixelProcessor) explained, AFAIK, the entitlements file contains the permissions required by the app, and which must be granted by the OS. I tried on my Mac mini using entitlements and it worked like a charm. So your app's problem wasn't that it was not able to find the JRE, but it was that the JRE libraries did not have permissions to be loaded. Exactly, this entitlement:

<key>com.apple.security.cs.disable-library-validation</key>
<true/>

tells the OS not to validate the libraries (.dylib files). So, problem fixed!!!

So many thanks to @AstroPixelProcessor!!!

@fvarrui fvarrui closed this as completed Apr 8, 2022
@EasyG0ing1
Copy link
Contributor

@fvarrui

So your app's problem wasn't that it was not able to find the JRE, but it was that the JRE libraries did not have permissions to be loaded.

Ah! That makes perfect sense. And yes, thanks to @AstroPixelProcessor for this solution ...

Next item on the agenda ... LINUX! And I don't even know where to begin.

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 8, 2022

Change platform property from mac to linux 😅 that's what I told you last time for building for mac. Good luck! 😄

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 8, 2022

No, seriously now. You can do two things:

  1. Set platform=linux and run mvn clean package from a Linux system (easiest way)

  2. Set platform=linux, jdkPath=path/to/linux/jdk and run mvn clean package -Djavafx.platform=linux from any system.

And, of course, set linuxConfig.generateDeb=true and/or linuxConfig.generateRpm=true, and linuxConfig.iconFile=path/to/png/file.

@fvarrui
Copy link
Contributor Author

fvarrui commented Apr 8, 2022

Once you have managed to build your app for all platforms, it would be a good idea to use GitHub Action workflows to generate each installation artifact in the cloud. ASAP I'm going to make an example.

@AstroPixelProcessor
Copy link

@fvarrui

So your app's problem wasn't that it was not able to find the JRE, but it was that the JRE libraries did not have permissions to be loaded.

Ah! That makes perfect sense. And yes, thanks to @AstroPixelProcessor for this solution ...

Next item on the agenda ... LINUX! And I don't even know where to begin.

Excellent, glad to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants