You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Quarkus从3.8升级至3.15.5失败:@QuarkusTest单元测试报错

Quarkus 3.15.5升级后@QuarkusTest单元测试报错问题

我尝试将Quarkus从3.8版本升级至3.15.5版本,运行官方升级命令耗时6小时后失败,转而手动升级项目。升级完成后,带有@QuarkusTest注解的单元测试无法运行,报错信息如下:

java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.smallrye.graphql.client.deployment.SmallRyeGraphQLClientProcessor#buildClientModel threw an exception: java.lang.NullPointerException: Cannot invoke "org.jboss.jandex.ClassInfo.methods()" because the return value of "org.jboss.jandex.IndexView.getClassByName(org.jboss.jandex.DotName)" is null

该错误源自Smallrye GraphQL Client库,详细栈信息为:

[error]: Build step io.quarkus.smallrye.graphql.client.deployment.SmallRyeGraphQLClientProcessor#buildClientModel threw an exception: java.lang.NullPointerException: Cannot invoke "org.jboss.jandex.ClassInfo.methods()" because the return value of "org.jboss.jandex.IndexView.getClassByName(org.jboss.jandex.DotName)" is null
    at io.smallrye.graphql.client.model.helper.TypeModel.hasScalarConstructor(TypeModel.java:268)
    at io.smallrye.graphql.client.model.helper.TypeModel.isScalar(TypeModel.java:258)
    at io.smallrye.graphql.client.model.helper.OperationModel.recursionCheckedFields(OperationModel.java:92)
    at io.smallrye.graphql.client.model.helper.OperationModel.fields(OperationModel.java:76)
    at io.smallrye.graphql.client.model.helper.OperationModel.recursionCheckedFields(OperationModel.java:95)
    at io.smallrye.graphql.client.model.helper.OperationModel.fields(OperationModel.java:76)

网上相关资料均指向Jandex问题,但尝试多种方法后仍未解决。当前环境配置:Java 17、Gradle 8.13、Quarkus 3.15.5,恳请各位提供解决思路。

可能的解决方向

  • 重新生成Jandex索引:手动升级可能导致索引不完整,执行./gradlew jandex命令重新生成项目的Jandex索引,确保所有项目类和依赖类都被正确索引。同时检查quarkus-jandex-plugin的版本是否与Quarkus 3.15.5兼容,避免版本不匹配。
  • 统一SmallRye GraphQL Client依赖版本:Quarkus 3.15.5绑定了特定版本的SmallRye组件,手动升级可能出现依赖版本冲突。检查build.gradle文件,确保所有SmallRye相关依赖都通过Quarkus BOM管理,不要手动指定版本,执行./gradlew dependencies查看依赖树,排查并修正版本不一致的依赖。
  • 检查GraphQL客户端实体类:报错是在处理类型模型时找不到对应类,可能是项目中GraphQL客户端接口引用的DTO/实体类未被正确索引,或者类路径缺失。检查这些实体类是否在编译时被包含,没有被排除在Jandex索引范围外。
  • 清理构建缓存:Gradle的旧缓存可能残留旧版本的类或索引数据,执行./gradlew clean build --no-build-cache彻底清理缓存后重新构建并运行测试。
  • 排查测试类的特殊配置:@QuarkusTest启动的测试可能加载了额外的扩展或自定义配置,检查测试类中是否引用了未被索引的外部类,或者测试配置是否修改了Quarkus的默认索引设置。
  • 验证Quarkus扩展版本一致性:手动升级可能遗漏部分扩展的版本更新,确保所有Quarkus扩展(如quarkus-smallrye-graphql-client)的版本都是3.15.5,避免因扩展版本不兼容导致的构建错误。

内容的提问来源于stack exchange,提问作者Andrey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 22:06:16