【问题标题】:Error: Classes that should be initialized at run time got initialized during image building: org.conscrypt.Conscrypt was unintentionally initialized错误:应该在运行时初始化的类在图像构建期间被初始化:org.conscrypt.Conscrypt 被无意初始化
【发布时间】:2020-12-26 23:59:16
【问题描述】:

使用 Java 11.0.9 (GraalVM CE 20.3.0) 和 Micronaut 2.2.1 应用程序,使用 Firebase 管理员 7.1.0,当我根据Micronaut documentation将我的应用程序打包为原生镜像时,出现以下错误:

$ ./gradlew nativeImage 
> Task :nativeImage
[application:15026]    classlist:   4,054.46 ms,  1.19 GB
[application:15026]        (cap):     504.32 ms,  1.19 GB
[application:15026]        setup:   1,827.02 ms,  1.19 GB
To see how the classes got initialized, use --trace-class-initialization=org.conscrypt.Conscrypt,org.conscrypt.OpenSSLProvider
[application:15026]     analysis:  29,787.52 ms,  3.90 GB
Error: Classes that should be initialized at run time got initialized during image building:
 org.conscrypt.Conscrypt was unintentionally initialized at build time. To see why org.conscrypt.Conscrypt got initialized use --trace-class-initialization=org.conscrypt.Conscrypt
org.conscrypt.OpenSSLProvider was unintentionally initialized at build time. To see why org.conscrypt.OpenSSLProvider got initialized use --trace-class-initialization=org.conscrypt.OpenSSLProvider

Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

> Task :nativeImage FAILED

FAILURE: Build failed with an exception.

问题是由包org.conscrypt 中的类引起的。相关的依赖来自 com.google.cloud:google-cloud-firestore:1.35.0 获取 org.conscrypt:conscrypt-openjdk-uber:2.2.1

我对 GraalVM 非常陌生,而且远不了解导致此类问题的原因。但是,我注意到应该可以将一些参数传递给native-image,例如--initialize-at-build-time

我的问题是如何解决这个问题?是否有要创建的配置文件以及 Micronaut 从选项中读取以转发到 native-image 可执行文件?

【问题讨论】:

    标签: java google-cloud-firestore micronaut graalvm graalvm-native-image


    【解决方案1】:

    这个问题是由com.google.cloud:google-cloud-firestore:1.35.0 以及它如何使用它的依赖关系引起的。此依赖项不支持开箱即用的原生图像。

    我们正在努力在这个官方存储库中添加对 GraalVM 的支持: https://github.com/GoogleCloudPlatform/google-cloud-graalvm-support

    将此库添加为编译依赖项可解决此问题。

    关于使用 Micronaut 的原生镜像配置,您可以通过配置文件传递选项。假设您的 groupId 是 com.acme 并且您的 artifactId 是 acme-module1,那么您需要在项目中使用您的内容创建文件 src/main/resources/META-INF/native-image/com/acme/acme-module1/native-image.properties

    Args = ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-13
      • 2012-05-14
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      相关资源
      最近更新 更多