当前位置: 首页 > 知识库问答 >
问题:

javafx graalvm错误:应该在运行时初始化的类在映像构建期间被初始化

陈野
2023-03-14

提前谢谢。

所以我试图用Maven部署JavaFX应用程序。

它给了我这个错误

[Sat Apr 03 20:52:20 PKT 2021][INFO] We will now compile your code for x86_64-microsoft-windows. This may take some time.
[Sat Apr 03 20:52:24 PKT 2021][INFO] [SUB] Warning: Ignoring server-mode native-image argument --no-server.
[Sat Apr 03 20:52:34 PKT 2021][INFO] [SUB] [org.quiz.app:13608]    classlist:   8,862.50 ms,  0.96 GB
[Sat Apr 03 20:52:39 PKT 2021][INFO] [SUB] [org.quiz.app:13608]        (cap):   3,337.64 ms,  1.18 GB
[Sat Apr 03 20:52:41 PKT 2021][INFO] [SUB] [org.quiz.app:13608]        setup:   7,150.97 ms,  1.18 GB
[Sat Apr 03 20:53:08 PKT 2021][INFO] [SUB] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[Sat Apr 03 20:53:08 PKT 2021][INFO] [SUB] SLF4J: Defaulting to no-operation (NOP) logger implementation
[Sat Apr 03 20:53:08 PKT 2021][INFO] [SUB] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB] To see how the classes got initialized, use --trace-class-initialization=org.slf4j.LoggerFactory
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB] [org.quiz.app:13608]     analysis:  71,925.59 ms,  3.23 GB
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB] Error: Classes that should be initialized at run time got initialized during image building:
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]  org.slf4j.LoggerFactory was unintentionally initialized at build time. To see why org.slf4j.LoggerFactory got initialized use --trace-class-initialization=org.slf4j.LoggerFactory
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB] com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]  org.slf4j.LoggerFactory was unintentionally initialized at build time. To see why org.slf4j.LoggerFactory got initialized use --trace-class-initialization=org.slf4j.LoggerFactory
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:539)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:226)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:735)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:735)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:558)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:471)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
[Sat Apr 03 20:53:53 PKT 2021][INFO] [SUB]      at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
[Sat Apr 03 20:53:54 PKT 2021][INFO] [SUB] Error: Image build request failed with exit status 1
[Sat Apr 03 20:53:54 PKT 2021][INFO] Additional information: Objectfile should be called org.quiz.app.obj but we didn't find that under F:\JavaFX\QuizApp\QuizApp\QuizApp\QuizApp\target\client\x86_64-windows\gvm
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[Sat Apr 03 20:53:54 PKT 2021][SEVERE] Compiling failed.
[INFO] Total time:  01:46 min
[INFO] Finished at: 2021-04-03T20:53:54+05:00
Check the log files under F:\JavaFX\QuizApp\QuizApp\QuizApp\QuizApp\target\client\x86_64-windows\gvm\log
And please check https://docs.gluonhq.com/client/ for more information.

我知道为什么它会给出错误。我正在使用Firebase。所以在构建时间初始化的类很少。那么我如何避免它呢?

我评论了我在我的项目中做的所有Firebase代码,并再次测试了它,然后它工作正常。但是当我再次包含Firebase时,我面临这个问题。任何帮助请

共有1个答案

夏星阑
2023-03-14

可以多亏了何塞·佩雷达

我找到了解决办法。

所以首先我创建了src/main/resources/META-INF/subscriber/config/initbuildtime文件,这个目录必须相同。initbuildtime是文件名。没有扩展名的文件。

在那之后

<nativeImageArgs>
                 <arg>--allow-incomplete-classpath</arg>
                 <arg>--initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger</arg>
                    </nativeImageArgs>

这个代码里面的pom.xml文件中的插件和它。我的项目构建良好。希望,这将有助于其他人。

感谢何塞·佩雷达,他真的帮了我很多。他是个伟大的人。

 类似资料:
  • 我正在开发我的第一个 Swing 应用程序,现在提出了一个难题:在静态初始化期间或开始实际执行后执行引导和资源初始化。我是什么意思...我有单例: 因此,方法如下所示 或者,也许我在启动后手动初始化资源,然后运行它。逻辑上正确的方式是什么?

  • 我正在使用以下堆栈运行一个简单的Java应用程序(只是一个RESTendpoint,一个“Hello”响应——正是Quarkus maven原型生成的示例,没有修改): Quarkus(微轮廓) JDK 1.8 HotSpot 1.8.0_231-b11 GraalVM 19.3.0(本地图像) MacOS Catalina 第一个错误是(尽管这似乎不是主要问题): 真正的问题(我认为)在这里:

  • 在“初始化Java工具”期间发生内部错误。无法初始化类org.eclipse.jdt.core。JavaConventions在Eclipse中下载AspectJ开发工具后。我在用Spring靴。 我不知道是什么问题。

  • jmockit无法在Eclipse中初始化:java.lang.IllegalStateException:在JDK 9上运行需要-javaAgent://jmockit-1.n.jar或-djdk.attach.AllowAttachSelf 如果我添加VM参数,它可以正常工作。 我为什么要加上那个论点?并没有说在JDK 9上运行时需要这样做。是的,JRE系统库指向JDK,而且jmockit j

  • 我正在用夸库斯构建一个原生图像,graal分析失败了,出现错误: 它正确且逻辑地声明随机数生成器提供程序的类应该在运行时初始化。但是,与文档中不同的是,没有给出调用路径,因为: 对象已在没有本机映像初始化检测的情况下初始化,并且无法跟踪堆栈跟踪 我不知道如何重组我的代码来支持这一点,而且就我所知,我并没有做任何真正奇怪的事情。为了准备这个问题,我粗暴地将涉及类的代码从中移到一起,现在它驻留在和中。

  • 我有以下Java代码: 但是,当我运行它时,它会抛出以下错误: 我在do之前初始化了变量。while 循环,并在 try. 中设置值。捕获循环。似乎尚未设置该变量。抱歉,如果这是一个相当基本的问题,但我似乎无法弄清楚。