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

Springboot3 + Java17 打包后运行报错 #124

Open
Bahramudin opened this issue Apr 27, 2023 · 4 comments
Open

Springboot3 + Java17 打包后运行报错 #124

Bahramudin opened this issue Apr 27, 2023 · 4 comments

Comments

@Bahramudin
Copy link

Bahramudin commented Apr 27, 2023

打包正常结束,加密包正常生成,可是运行的时候包如下错(这个是不是因为JDK版本过高的问题):

Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make field private final jdk.internal.loader.URLClassPath java.net.URLClassLoader.ucp accessible: module java.base does not "opens java.net" to unnamed module @4cdbe50f
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
        at io.xjar.reflection.XReflection.field(XReflection.java:20)
        at io.xjar.boot.XBootClassLoader.<init>(XBootClassLoader.java:41)
        at io.xjar.boot.XJarLauncher.createClassLoader(XJarLauncher.java:31)
        at org.springframework.boot.loader.ExecutableArchiveLauncher.createClassLoader(ExecutableArchiveLauncher.java:109)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:55)
        at io.xjar.boot.XJarLauncher.launch(XJarLauncher.java:26)
        at io.xjar.boot.XJarLauncher.main(XJarLauncher.java:22)
panic: exit status 1

该问题怎么解决?
我是通过Maven插件形式生成的加密jar包(也式main方法形式)都是包这个错。

Note:我在运行命令也加上 了--add-opens java.base/jdk.internal.loader=ALL-UNNAMED还是没有解决问题一样报错。这个库能不能升级一下,我看了代码已经是好几年前的了,太老了。

@powerttt
Copy link

./xjar /c/env/jdk/jdk-17.0.5/bin/java --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED -jar xxx.xjar
可行

@laowang6984
Copy link

@powerttt 我这边也是springboot3 + java17,启动后报无法加载主类,加密前的包能正常启动

@linxueyi2230
Copy link

@powerttt 我这边也是springboot3 + java17,启动后报无法加载主类,加密前的包能正常启动

从源码看到,这是由于springboot3的启动类是org.springframework.boot.loader.launch.JarLauncher,springboot2的启动类是org.springframework.boot.loader.JarLauncher,而作者没有兼容springboot3导致

@MisterChangRay
Copy link

看老大一直不解决。
于是拉取了新分支支持springboot3
目前在springboot3.2.3+jdk17中验证通过
项目地址 https://github.com/MisterChangRay/xjar4springboot3

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

5 participants