beryx / badass-runtime-plugin

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

jpackage failing for WiX Toolset #71

Open conor-byrne opened 4 years ago

conor-byrne commented 4 years ago

JDK: 14 Gradle 4.8.1 Badass-Runtime-Plugin: 1.11.4 WiX Toolset: 3.11 Windows 10

Running jpackage gradle task results in the following:

> Task :jpackage
WARNING: Using incubator modules: jdk.incubator.jpackage
java.io.IOException: Command [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe,
-nologo,
-spdb,
-ext, WixUtilExtension,
-out, C:\Users\Conor\JMBusFinder\build\my-package\JMBusFinderInstaller-1.0.msi, -sice:ICE27, 
-loc, C:\Users\Conor\AppData\Local\Temp\jdk.incubator.jpackage3608988343189584673\config\MsiInstallerStrings_en.wxl,
C:\Users\Conor\AppData\Local\Temp\jdk.incubator.jpackage3608988343189584673\wixobj\main.wixobj,
C:\Users\Conor\AppData\Local\Temp\jdk.incubator.jpackage3608988343189584673\wixobj\bundle.wixobj]in
C:\Users\Conor\AppData\Local\Temp\jdk.incubator.jpackage3608988343189584673\images\win-msi.image\JMBusFinderInstaller
exited with 103 code

I'm fairly certain that this is a WiX issue due to light.exe having trouble with long path names: https://github.com/wixtoolset/issues/issues/5314 https://stackoverflow.com/questions/11921637/wix-canf-find-my-file-unable-to-load-file-error-lght0103

Feel free to close this issue, it's more of a PSA for others that might have the same problem.

sunsteam commented 4 years ago

Task :data2excel:jpackage WARNING: Using incubator modules: jdk.incubator.jpackage java.io.IOException: Command [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe, -nologo, -spdb, -ext, WixUtilExtension, -out, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpack age1856809374289184943\images\win-exe.image\data2excel_win_x64-1.0.0.msi, -sice:ICE91, -ext, WixUIExtension, -loc, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage18568093742891 84943\config\MsiInstallerStrings_en.wxl, -b, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage1856809374289184943\config, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage1 856809374289184943\wixobj\main.wixobj, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage1856809374289184943\wixobj\bundle.wixobj]in C:\Users\juno\AppData\Local\Temp\jdk.incubator .jpackage1856809374289184943\images\win-msi.image\data2excel_win_x64 exited with 311 code

same problem but with 311 code. for reference


runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        //不显示黑框
        noConsole = true
    }
    jpackage {
        if (org.gradle.internal.os.OperatingSystem.current().windows) {
            jpackageHome = "D:\\develop_env\\jdk-14.0.2"
            //installerType = 'msi'
            installerName = project.name + '_win_x64'
            installerOptions += ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-shortcut']
            imageOptions = ['--icon', 'src/main/resources/icon/hellofx.ico']
        }
    }
}

use jpackage in openJDK 14 but compile JDK is amazon-corretto-11-x64-windows-jdk

siordache commented 4 years ago

@conor-byrne In this jpackage bug it was also reported that light.exe failed with code 102, but the problem in this case is not a long path name.

@conor-byrne @sunsteam Please add the line

installerOptions += ['--verbose']

at the end of your jpackage block in build.gradle. Then, execute :

gradlew -i jpackage

and post here the output of the jpackage task. Maybe it helps identifying the problem.

sunsteam commented 4 years ago

:data2excel:jre (Thread[Execution worker for ':',5,main]) completed. Took 13.527 secs.
:data2excel:jpackageImage (Thread[Execution worker for ':',5,main]) started.

> Task :data2excel:jpackageImage
Caching disabled for task ':data2excel:jpackageImage' because:
  Build cache is disabled
Task ':data2excel:jpackageImage' is not up-to-date because:
  Value of input property 'jpackageData.installerOptions' has changed for task ':data2excel:jpackageImage'
input subdir: data2excel-shadow
Starting process 'command 'D:\develop_env\jdk-14.0.2/bin/jpackage.exe''. Working directory: D:\workspace\dts-tools\data2excel Command: D:\develop_env\jdk-14.0.2/bin/jpackage.exe --type
 app-image --input D:\workspace\dts-tools\data2excel\build\install\data2excel-shadow\lib --main-jar data2excel-1.0.0-all.jar --main-class com.juno.converter.Launcher --dest D:\workspac
e\dts-tools\data2excel\build\jpackage --name data2excel --app-version 1.0.0 --runtime-image D:\workspace\dts-tools\data2excel\build\jre --icon src/main/resources/icon/hellofx.ico
Successfully started process 'command 'D:\develop_env\jdk-14.0.2/bin/jpackage.exe''
WARNING: Using incubator modules: jdk.incubator.jpackage

:data2excel:jpackageImage (Thread[Execution worker for ':',5,main]) completed. Took 1.823 secs.
:data2excel:jpackage (Thread[Execution worker for ':',5,main]) started.

> Task :data2excel:jpackage
Caching disabled for task ':data2excel:jpackage' because:
  Build cache is disabled
Task ':data2excel:jpackage' is not up-to-date because:
  Task has failed previously.
Starting process 'command 'D:\develop_env\jdk-14.0.2/bin/jpackage.exe''. Working directory: D:\workspace\dts-tools\data2excel Command: D:\develop_env\jdk-14.0.2/bin/jpackage.exe --type
 exe --dest D:\workspace\dts-tools\data2excel\build\jpackage --name data2excel_win_x64 --app-version 1.0.0 --app-image D:\workspace\dts-tools\data2excel\build\jpackage\data2excel --win
-per-user-install --win-dir-chooser --win-menu --win-shortcut --verbose
Successfully started process 'command 'D:\develop_env\jdk-14.0.2/bin/jpackage.exe''
WARNING: Using incubator modules: jdk.incubator.jpackage
Running [candle.exe, /?]
Running [C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe, /?]
Windows Installer XML Toolset Compiler version 3.11.2.4516
Copyright (c) .NET Foundation and contributors. All rights reserved.

.......something usage help info

Running [light.exe, /?]
Running [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe, /?]
Windows Installer XML Toolset Linker version 3.11.2.4516
Copyright (c) .NET Foundation and contributors. All rights reserved.

.......something usage help info

Environment variables:
   WIX_TEMP   overrides the temporary directory used for cab creation, msm exploding, ...

For more information see: http://wixtoolset.org/
检测到 [candle.exe] 版本 [3.11.2.4516]。
检测到 [light.exe] 版本 [3.11.2.4516]。
检测到 WiX 3.11.2.4516。正在启用高级清除操作。
MSI ProductCode:4383aaa5-bb97-31e5-9e70-a22f11e33ab3。
MSI UpgradeCode:e63d5d4d-c07a-3d57-b914-8bd85a2ded10。
使用默认程序包资源 main.wxs [主 WiX 项目文件](将 main.wxs 添加到 resource-dir 中以进行定制)。
使用默认程序包资源 overrides.wxi [覆盖 WiX 项目文件](将 overrides.wxi 添加到 resource-dir 中以进行定制)。
正在准备 MSI 配置: C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\images\win-exe.image\data2excel_win_x64-1.0.0.msi。
正在生成 MSI: C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\images\win-exe.image\data2excel_win_x64-1.0.0.msi。
Running [C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe, -nologo, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config\main.wxs, -ext, WixUtilExt
ension, -arch, x64, -out, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\wixobj\main.wixobj, -dJpAppDescription=data2excel_win_x64, -dJpAppVersion=1.0.0, -
dJpInstallDirChooser=yes, -dJpProductCode=4383aaa5-bb97-31e5-9e70-a22f11e33ab3, -dJpAppName=data2excel_win_x64, -dJpAllowUpgrades=yes, -dJpProductUpgradeCode=e63d5d4d-c07a-3d57-b914-8b
d85a2ded10, -dJpAppVendor=未知, -dJpConfigDir=C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config]in C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpack
age16598257931579607499\images\win-msi.image\data2excel_win_x64
main.wxs
Running [C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe, -nologo, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config\bundle.wxf, -ext, WixUtilE
xtension, -arch, x64, -out, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\wixobj\bundle.wixobj]in C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage1
6598257931579607499\images\win-msi.image\data2excel_win_x64
bundle.wxf
Running [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe, -nologo, -spdb, -ext, WixUtilExtension, -out, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage165982579315796074
99\images\win-exe.image\data2excel_win_x64-1.0.0.msi, -sice:ICE91, -ext, WixUIExtension, -loc, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config\MsiIns
tallerStrings_en.wxl, -b, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage1659825793157960749
9\wixobj\main.wixobj, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\wixobj\bundle.wixobj]in C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage1659825
7931579607499\images\win-msi.image\data2excel_win_x64
C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config\main.wxs(25) : error LGHT0311 : A string was provided with characters that are not available in the s
pecified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following
attributes: Product/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.
C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config\bundle.wxf(24) : error LGHT0311 : A string was provided with characters that are not available in the
 specified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the followin
g attributes: Product/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.

.... similar error

java.io.IOException: Command [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe, -nologo, -spdb, -ext, WixUtilExtension, -out, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpack
age16598257931579607499\images\win-exe.image\data2excel_win_x64-1.0.0.msi, -sice:ICE91, -ext, WixUIExtension, -loc, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage1659825793157
9607499\config\MsiInstallerStrings_en.wxl, -b, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpacka
ge16598257931579607499\wixobj\main.wixobj, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\wixobj\bundle.wixobj]in C:\Users\juno\AppData\Local\Temp\jdk.incu
bator.jpackage16598257931579607499\images\win-msi.image\data2excel_win_x64 exited with 311 code
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Executor.executeExpectSuccess(Executor.java:73)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WixPipeline.execute(WixPipeline.java:131)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WixPipeline.buildMsi(WixPipeline.java:95)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinMsiBundler.buildMSI(WinMsiBundler.java:512)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinMsiBundler.bundle(WinMsiBundler.java:394)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinExeBundler.bundle(WinExeBundler.java:110)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinExeBundler.execute(WinExeBundler.java:83)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Arguments.generateBundle(Arguments.java:641)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Arguments.processArguments(Arguments.java:514)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.main.Main.execute(Main.java:97)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.main.Main.main(Main.java:51)
jdk.incubator.jpackage.internal.PackagerException: java.io.IOException: Command [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe, -nologo, -spdb, -ext, WixUtilExtension, -out, C
:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\images\win-exe.image\data2excel_win_x64-1.0.0.msi, -sice:ICE91, -ext, WixUIExtension, -loc, C:\Users\juno\App
Data\Local\Temp\jdk.incubator.jpackage16598257931579607499\config\MsiInstallerStrings_en.wxl, -b, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config, C:
\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\wixobj\main.wixobj, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\wixobj\bundle.
wixobj]in C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\images\win-msi.image\data2excel_win_x64 exited with 311 code
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinMsiBundler.bundle(WinMsiBundler.java:397)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinExeBundler.bundle(WinExeBundler.java:110)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinExeBundler.execute(WinExeBundler.java:83)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Arguments.generateBundle(Arguments.java:641)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Arguments.processArguments(Arguments.java:514)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.main.Main.execute(Main.java:97)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.main.Main.main(Main.java:51)
Caused by: java.io.IOException: Command [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe, -nologo, -spdb, -ext, WixUtilExtension, -out, C:\Users\juno\AppData\Local\Temp\jdk.incu
bator.jpackage16598257931579607499\images\win-exe.image\data2excel_win_x64-1.0.0.msi, -sice:ICE91, -ext, WixUIExtension, -loc, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16
598257931579607499\config\MsiInstallerStrings_en.wxl, -b, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config, C:\Users\juno\AppData\Local\Temp\jdk.incub
ator.jpackage16598257931579607499\wixobj\main.wixobj, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\wixobj\bundle.wixobj]in C:\Users\juno\AppData\Local\Te
mp\jdk.incubator.jpackage16598257931579607499\images\win-msi.image\data2excel_win_x64 exited with 311 code
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Executor.executeExpectSuccess(Executor.java:73)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WixPipeline.execute(WixPipeline.java:131)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WixPipeline.buildMsi(WixPipeline.java:95)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinMsiBundler.buildMSI(WinMsiBundler.java:512)
        at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.WinMsiBundler.bundle(WinMsiBundler.java:394)
        ... 6 more

> Task :data2excel:jpackage FAILED
:data2excel:jpackage (Thread[Execution worker for ':',5,main]) completed. Took 13.43 secs.

FAILURE: Build failed with an exception.

look like charset problem, below param of light.exe used en-US config , code page 1252, -loc, C:\Users\juno\AppData\Local\Temp\jdk.incubator.jpackage16598257931579607499\config\MsiInstallerStrings_en.wxl

https://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/specifying_cultures_to_build.html

before plugin update to fix , i tried build manually and success as below

jpackage {
        if (org.gradle.internal.os.OperatingSystem.current().windows) {
            jpackageHome = "D:\\develop_env\\jdk-14.0.2"
            imageOptions = ['--icon', 'src/main/resources/icon/hellofx.ico']
            imageOptions += ['--vendor', 'juno']
            installerName = project.name + '_win_x64'
            installerOptions += ['--temp',"${buildDir}/tempDir"]
            installerOptions += ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-shortcut']
            //installerOptions += ['--verbose']
        }
    }

first, add installerOptions += ['--temp',"${buildDir}/tempDir"] in jpackage block

it will save the temp file , but need delete or clean the dir before next build

and cd to build\tempDir\images\win-msi.image\appname dir

"C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe" -nologo -spdb -cultures:zh-CN -ext WixUtilExtension -out ..\..\..\..\jpackage\install\data2excel_win_x64-1.0.0.msi -sice:ICE91 -ext WixUIExtension -loc ..\..\..\config\MsiInstallerStrings_zh_CN.wxl -b ..\..\..\config ..\..\..\wixobj\main.wixobj ..\..\..\wixobj\bundle.wixobj

change wix path and appName and language to yours, like -cultures:zh-CN and MsiInstallerStrings_zh_CN.wxl , and run

the msi will be found in build\jpacakge\install

image

siordache commented 4 years ago

@sunsteam It lloks like this problem will be fixed in JDK 16 - see https://bugs.openjdk.java.net/browse/JDK-8232621.

sunsteam commented 4 years ago

@siordache Official step too slow, can plugin catch the error in gradle and run good command to fix ?

siordache commented 4 years ago

@sunsteam I don't think that this is possible. But did you try to build your application using JDK16 Early-Access? The jpackage bug should be fixed in this version.

sunsteam commented 4 years ago

@siordache I download jdk16 ,read the patch log and jpackage -help, but I can't find how to send arugus to jpackage or light.exe. If i want the language is zh-CN, what should i do in gradle? default config is still en-us and failed.

siordache commented 4 years ago

I created an example project. You need the latest JDK 16 Early-Access Build.

siordache commented 4 years ago

@sunsteam The above solution should fix your problem. However, it is only a workaround. I discovered the real cause of the error and I reported it on the OpenJDK mailing list. The issue is tracked now by JDK-8255619. It will probably be fixed in the next Early-Access release.

sunsteam commented 3 years ago

@siordache It can work, thank you.

drewjosh commented 3 years ago

Hello there, I'm on Windows 10 (MacBook Pro Dual Boot) using JDK 16, Wix Toolset 3.11.2 and I was facing the error 311 as well. After running the jpackage command with --verbose I found the following error:

error LGHT0311 : A string was provided with characters that are not available in the specified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Product/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.

This is my jpackage command: jpackage \ --input JAR \ --main-jar $jarFile \ --name "$appName" \ --app-version "$version" \ --description "$description" \ --vendor "$vendor" \ --copyright "$copyright" \ --icon Icon/bioapp_icon.ico \ --win-shortcut \ --win-menu \ --win-menu-group "$appName" \ --license-file JAR/license.txt \ --win-upgrade-uuid "xxxxx" \ --verbose

I found out that my license.txt was causing the problem. It was AINSI encoded and had unvalid characters (ä, ö, ü from the German language). After changing to UTF-8 and replacing the correct characters everything worked out.

Maybe this helps someone facing this issue. Cheers