What is the cause of io.netty.channel.StacklessClosedChannelException on deplyoment - java

So I'm developing a JavaFX app and when I run it on IntelliJ it works perfectly without any errors nor warnings but when I deploy it using Jpackage on sending WebSockets it throws the exception io.netty.channel.StacklessClosedChannelException
here's my Jpackage code
jpackage -t exe --name "App Name" --description "App Description" --app-version 1.1.0 --input input --dest output --icon favicon.ico --main-jar app.jar --module-path Path\to\javafx-jmods-17.0.1 --add-modules javafx.controls,javafx.base,javafx.graphics,javafx.web,javafx.fxml,java.sql,javafx.media --win-shortcut --win-menu --win-console
I tried narrowing the error down and it looks like its caused by ChannelFuture.sync() although this only occurs during packaging of the jar
Am I missing a java option or an export that I overlooked by mistake?
Any help would be appreciated, Thanks in advance.

Related

java.lang.NoClassDefFoundError: javax/swing/SwingUtilities when app is packaged using jpackage

I'm creating a Kotlin compose app and I want to create a distributable package for Mac OS using jpackage (I know about the packageDmg Gradle task, but now I want to go around it).
The jar file works fine but the installed app crashes on start. By running the app from terminal (open /Applications/MyApp/Contents/MacOS/myapp) I found out that it throws this exception java.lang.NoClassDefFoundError: javax/swing/SwingUtilities
I've included all modules that the suggestRuntimeModules task suggested but it does not include anything that seems swing related to me.
I'm on an M1 mac with and java --version gives me this java 15.0.2 2021-01-19
Here is my packaging command:
jpackage --input ./ \
--name myApp \
--main-jar myapp-macos-x64-1.1.3.jar \
--type pkg \
--icon ../../../src/main/resources/icon.icns \
--app-version '1.1.3' \
--mac-package-name "My App" \
--vendor "My App" \
--add-modules java.instrument,java.net.http,java.prefs,java.sql,jdk.unsupported

How to create and run a jar file with manifest file to support MySQL?

I'm trying to build and run a Java application that relies on 'mysql-connector-java-8.0.27.jar'. I currently to this with the following commands using Terminal on MacOS, which works fine, however it doesn't work on Windows, so I'm trying an alternative approach using Docker, which results in an MySQL driver error message when running the app.
Steps to manually build and run using Terminal.
step 1: find . -name "*.java" | xargs javac -d ./target
step 2: jar cfme my_app.jar manifest.txt Main -C ./target/ .
step 3: java -jar my_app.jar
The manifest file includes a reference to the MySQL jar-file:
Manifest-Version: 1.0
Class-Path: lib/mysql-connector-java-8.0.27.jar
As mentioned before, this solution works fine on Mac, but doesn't work on Windows.
So now I'm trying to use Docker to build and run the app instead. It was done this way before when the app didn't use MySQL and there was no need for the manifest file. I included steps to copy the manifest file in the Dockerfile as below, however when running the application I get an error: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3316/myDatabase. I didn't get this error when I built the app manually using the 3 steps I listed out above.
Contents of Dockerfile:
FROM openjdk:17-slim AS builder
COPY src /usr/src/app/src
COPY lib /usr/src/app/lib
COPY manifest.txt /usr/src/app/
WORKDIR /usr/src/app
RUN find . -name "*.java" | xargs javac -d ./target
RUN jar cfme my_app.jar manifest.txt Main -C ./target/ .
Steps to build and run the app using Docker:
1: docker build -t projects/my_app -f Dockerfile ./
2: docker run -ti projects/my_app sh
3: java -jar my_app.jar
How would I resolve the error or what would be a better approach to make this app more portable and easy to run on a different machine?
UPDATE 11/23:
I'm able to create a jar-file using Gradle, however when I run the application I get an error: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3316/myDatabase
This is the contents of of my build.gradle file:
plugins {
id 'java'
}
jar {
manifest {
attributes 'Main-Class': 'myApp.Main'
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'mysql:mysql-connector-java:8.0.27'
}
I'm new to Gradle, and appreciate any help with this. Thank you!

Missing JavaFX application class when using jPackage

I'm getting the message "Missing JavaFX application class com.ponderwhy.pikeinventory.PikeInventory" after deploying with jPackage.
Using AdoptOpenJDK 16, JavaFx-16, WiX 3.11 on Windows 10. My application runs fine when I use the following JVM options file.
# -classpath aka -cp
-cp D:/WS_Utility/PikeInventory/bin;D:/WS_Utility/Basic/bin;D:/WS_Utility/ancillary/bin;C:/Java/javafx-sdk-16/lib;C:/Java/controlsfx-jfx-13/controlsfx-11.0.2.jar
# -modulepath aka -p
-p C:/Java/javafx-sdk-16/lib;D:/WS_Utility/basic/bin;D:/WS_Utility/Ancillary/bin;D:/WS_Utility/PikeInventory/bin;C:/Java/controlsfx-jfx-13/controlsfx-11.0.2.jar
--add-modules=ALL-MODULE-PATH
--add-exports javafx.base/com.sun.javafx.collections=ALL-UNNAMED
--add-exports javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
--add-exports javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED
com.ponderwhy.pikeinventory.PikeInventory
When I use jPackage to build an.exe file using the following jPackage commands:
--type exe
--app-version 1.0.1
--description "Pike Inventory"
--name PikeInventory
--vendor PonderWhy
--verbose
--java-options -splash:$APPDIR//RockF7.jpg
--input D:/Dev/TrainInv/jPackage
--icon D:/Dev/TrainInv/jPackage/LocoFront.ico
--main-jar PikeInventory.jar
--main-class com.ponderwhy.pikeinventory.PikeInventory
--module-path C:/Java/javafx-jmods-16;C:/Java/controlsfx-jfx-13;C:/Java/JDK-16/jmods;D:/Dev/TrainInv/jPackage
--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web
--win-console
--win-dir-chooser
--win-menu
--win-menu-group PikeInventory
--win-shortcut
# --win-upgrade-uuid PkInv
I have the 2 environment variables set that I find some references to.
PATH_TO_FX=C:\Java\javafx-sdk-16\lib
PATH_TO_FX_MODS=C:\Java\javafx-jmods-16
All three of my projects, Basic, Ancillary and PikeInventory have module-info.class.
The jPackage builds, deploys and installs without error. My splash comes up then the missing class message.
I am at a loss at what to try next to resolve my problem.
Any help would be greatly appreciated.
Peter

IO Exception in Java Packager: Exec failed with code 2 command

I want to create executable bundle for windows from java's jar application using the javapackager but facing issues.
Running cmd command
javapackager -deploy -native -outdir packages -outfile Final -srcdir . -srcfiles Hello.jar -appclass sample.Main
Exception
No base JDK. Package will use system JRE.
No base JDK. Package will use system JRE.
Creating app bundle: Main in C:\Users\DELL\Desktop\Java Packager\packages\bundles
Result application bundle: C:\Users\DELL\Desktop\Java Packager\packages\bundles
java.io.IOException: Exec failed with code 2 command [[C:\Program Files (x86)\InnoSetup6\iscc.exe,
/oC:\Users\DELL\Desktop\Java Packager\packages\bundles,
C:\Users\DELL\AppData\Local\Temp\fxbundler6308867820319632690\images\win-exe.image\Main.iss] in
C:\Users\DELL\AppData\Local\Temp\fxbundler6308867820319632690\images\win-exe.image
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:165)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:138)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:132)
at com.oracle.tools.packager.windows.WinExeBundler.buildEXE(WinExeBundler.java:697)
at com.oracle.tools.packager.windows.WinExeBundler.bundle(WinExeBundler.java:366)
at com.oracle.tools.packager.windows.WinExeBundler.execute(WinExeBundler.java:173)
at com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:352)
at com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:319)
at com.sun.javafx.tools.packager.Main.main(Main.java:476)
Error: Bundler "EXE Installer" (exe) failed to produce a bundle.

What makes an app PowerPC based

So I coded an app in Xcode in Objective-C, which packages a jar file so that it should run as if it were executed in Terminal. The Xcode app runs, but the packaged jar that the app creates gives an error
The app file structure is
Foo.app
-Contents
--Info.plist
--MacOS
---foo.jar
---launcher
--Resources
I also ran chmod a+x on the launcher to make it executable
The contents of the launcher are
#!/bin/sh
cd "$( dirname "$0" )"
sudo java -Xmx1G -jar "foo.jar" -o true
When I try to run the packaged app it says that PowerPC apps are no longer supported.
After reviewing the code a few more times and noticed that when creating a launcher I used NSUnicodeStringEncoding instead of NSUTF8StringEncoding, which caused the app to not work.

Categories

Resources