java 运行gradle bootBuildImage错误:找不到基本名称jakarta.servlet.LocalStrings的包,语言环境en_US

6l7fqoea  于 2023-02-02  发布在  Java
关注(0)|答案(1)|浏览(222)

我不能在带有Springboot项目的rocty linux 9.1中运行gradle bootBuildImage。

Caused by: java.util.MissingResourceException: Can't find bundle for base name jakarta.servlet.LocalStrings, locale en_US
        at java.base@17.0.6/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2045) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
        at java.base@17.0.6/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1683) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
        at java.base@17.0.6/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1586) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
        at java.base@17.0.6/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1549) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
        at java.base@17.0.6/java.util.ResourceBundle.getBundle(ResourceBundle.java:858) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
        at jakarta.servlet.GenericServlet.\<clinit\>(GenericServlet.java:51) \~\[com.unimet.test.graalvm.GraalvmApplication:6.0.0\]
        ... 75 common frames omitted
system:rocty linux 9.1
build:gradle 7.6
run:gradle bootBuildImage

build.gradle:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.0.2'
    id 'io.spring.dependency-management' version '1.1.0'
    id 'org.graalvm.buildtools.native' version '0.9.18'
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-undertow")
    implementation("org.springframework.boot:spring-boot-starter-web") {
        exclude module: 'spring-boot-starter-tomcat'
    }
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
nszi6y05

nszi6y051#

这是由于缺少Jakarta Servlet API的元数据;本机映像正在尝试加载在构建时未包括在本机映像中的资源束。
我已经提交了a PR to fix that in the GraalVM metadata repository
同时,您可以将以下内容添加到项目中的新文件src/main/resources/META-INF/native-image/jakarta.servlet/jakarta.servlet-api/resource-config.json中:

{
  "bundles": [
    {
      "name": "jakarta.servlet.LocalStrings",
      "locales": [
        "und"
      ],
      "condition": {
        "typeReachable": "jakarta.servlet.GenericServlet"
      }
    },
    {
      "name": "jakarta.servlet.http.LocalStrings",
      "locales": [
        "und"
      ],
      "condition": {
        "typeReachable": "jakarta.servlet.http.HttpServlet"
      }
    }
  ]
}

相关问题