【问题标题】:Spring native erro on execute builded image执行构建映像时出现 Spring 本机错误
【发布时间】:2023-04-07 04:20:02
【问题描述】:

我正在做一个测试项目,我正在尝试使用 GRPC 实现 AOT,它可以通过 paketo 编译图像,但是在运行生成的图像时它显示错误:“io.grpc.netty 的本机反射配置. shaded.io.netty.channel.socket.nio.NioSocketChannel.() 丢失。”我尝试通过@TypeHint(types = NioServerSocketChannel.class) 来指导这个类的编译,但是没有成功。

项目:https://github.com/thukabjj/spring-boot-grpc/tree/main/simulacao

Print image execution

有没有人遇到过类似的错误?

【问题讨论】:

    标签: spring-boot grpc java-11 graalvm-native-image spring-native


    【解决方案1】:

    是的,你的提示缺少方法部分...这是我需要让我的 grpc 工作的提示(最后一个是你描述的错误)

    @TypeHints({ //
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerIndexField",
                fields = @FieldHint(name = "producerIndex", allowUnsafeAccess = true)), //
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerLimitField",
                fields = @FieldHint(name = "producerLimit", allowUnsafeAccess = true)), //
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueConsumerIndexField",
                fields = @FieldHint(name = "consumerIndex", allowUnsafeAccess = true)), //
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields",
                fields = @FieldHint(name = "producerIndex", allowUnsafeAccess = true)), //
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields",
                fields = @FieldHint(name = "producerLimit", allowUnsafeAccess = true)), //
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields",
                fields = @FieldHint(name = "consumerIndex", allowUnsafeAccess = true)), //
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.buffer.AbstractByteBufAllocator", access = AccessBits.ALL),
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.channel.ReflectiveChannelFactory", access = AccessBits.ALL),
        @TypeHint(typeNames = "io.grpc.netty.shaded.io.netty.channel.socket.nio.NioSocketChannel", methods = @MethodHint(name = "<init>")) })
    

    【讨论】:

    • 使用您的方法,我在执行 docker 映像时遇到了另一个错误:“br.com.agrupamento.AgrupamentoServiceGrpc.newBlockingStub(io.grpc.Channel) 的本机反射配置丢失”
    • 部分或全部这些应该在 grpc-java 1.41.0 中修复。
    • 唯一剩下的问题应该来自生成的 proto/grpc-service 代码。我计划添加一个 graalvm 本机提示提供程序作为 yidongnan/grpc-spring-boot-starter#577 的一部分。我还不确定,我是否会在 grpc-spring-boot-starter、grpc-java 或 protobuf 本身中这样做。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-13
    • 2018-12-15
    相关资源
    最近更新 更多