opensolon / opensolon/solon-examples

demo3038-auth_captcha 使用 GraalVM native image 打包后运行报错:Exception in thread "main" java.lang.IllegalStateException: java.util.zip.ZipException: zip END header not found

Open
#11 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
21
Forks
16
PR merge metrics
No merged PRs in 30d

Description

复现步骤


1. 通过 mvn package 把 demo3038-auth_captcha 项目打包 jar 包,并重命名为 demo.jar

2. 在 Rocky Linux 9 上运行 jar 包,并通过 agentlib 收集信息

2.1. 我的 Java 版本:

java --version                                                                                     130 ↵
java 21.0.4 2024-07-16 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.4+8.1 (build 21.0.4+8-LTS-jvmci-23.1-b41)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.4+8.1 (build 21.0.4+8-LTS-jvmci-23.1-b41, mixed mode, sharing)

2.2. 执行 jar 命令并收集信息:

java -agentlib:native-image-agent=config-merge-dir=/home/camio/demo-config/,config-write-period-secs=5,config-write-initial-delay-secs=1 -jar demo.jar

2.3. 访问浏览器,试用各种验证码,成功收集到了 GraalVM 需要的相关信息:

╰─➤  ll /home/camio/demo-config 
total 52K
drwxr-xr-x 2 camio camio    6 Aug 18 16:03 agent-extracted-predefined-classes
drwx------ 2 camio camio  180 Aug 18 16:04 agent-pid36461-20240818T080457Z.tmp14407388045284041076
-rw-r--r-- 1 camio camio  702 Aug 18 16:04 jni-config.json
-rw-r--r-- 1 camio camio   65 Aug 18 16:04 predefined-classes-config.json
-rw-r--r-- 1 camio camio    4 Aug 18 16:04 proxy-config.json
-rw-r--r-- 1 camio camio  28K Aug 18 16:04 reflect-config.json
-rw-r--r-- 1 camio camio 4.9K Aug 18 16:04 resource-config.json
-rw-r--r-- 1 camio camio   71 Aug 18 16:04 serialization-config.json

3. 把 jar 包编译成二进制包
native-image --enable-url-protocols=http,https -H:ConfigurationFileDirectories=/home/camio/demo-config -jar demo.jar demo

4. 运行二进制包,报错

报错信息:

╰─➤  /home/camio/demo
Exception in thread "main" java.lang.IllegalStateException: java.util.zip.ZipException: zip END header not found
        at org.noear.solon.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:57)
        at org.noear.solon.loader.JarLauncher.<init>(JarLauncher.java:42)
        at org.noear.solon.loader.JarLauncher.main(JarLauncher.java:65)
        at java.base@21.0.4/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.util.zip.ZipException: zip END header not found
        at java.base@21.0.4/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1649)
        at java.base@21.0.4/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1657)
        at java.base@21.0.4/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1495)
        at java.base@21.0.4/java.util.zip.ZipFile$Source.get(ZipFile.java:1458)
        at java.base@21.0.4/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:724)
        at java.base@21.0.4/java.util.zip.ZipFile.<init>(ZipFile.java:251)
        at java.base@21.0.4/java.util.zip.ZipFile.<init>(ZipFile.java:180)
        at java.base@21.0.4/java.util.jar.JarFile.<init>(JarFile.java:345)
        at java.base@21.0.4/java.util.jar.JarFile.<init>(JarFile.java:316)
        at java.base@21.0.4/java.util.jar.JarFile.<init>(JarFile.java:282)
        at org.noear.solon.loader.jar.AbstractJarFile.<init>(AbstractJarFile.java:39)
        at org.noear.solon.loader.jar.JarFile.<init>(JarFile.java:136)
        at org.noear.solon.loader.jar.JarFile.<init>(JarFile.java:131)
        at org.noear.solon.loader.jar.JarFile.<init>(JarFile.java:116)
        at org.noear.solon.loader.jar.JarFile.<init>(JarFile.java:106)
        at org.noear.solon.loader.archive.JarFileArchive.<init>(JarFileArchive.java:69)
        at org.noear.solon.loader.archive.JarFileArchive.<init>(JarFileArchive.java:65)
        at org.noear.solon.loader.Launcher.createArchive(Launcher.java:136)
        at org.noear.solon.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:53)
        ... 3 more

5. 求助:能否帮忙针对 demo3038-auth_captcha 这个例子给出一个可以通过 GraalVM native image 在 Linux 上成功打包并运行的方案?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the demo3038-auth_captcha example and reproduce the Maven packaging and native-image commands on Rocky Linux 9. Inspect the failure through org.noear.solon.loader.ExecutableArchiveLauncher and the reported ZipFile stack; done means the generated demo binary starts successfully without the ZipException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, linux
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.