I cant run gradle bootBuildImage in rocty linux 9.1 with a Springboot project.
Caused by: java.util.MissingResourceException: Can't find bundle for base name jakarta.servlet.LocalStrings, locale en_US
at [email protected]/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2045) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1683) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1586) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1549) \~\[com.unimet.test.graalvm.GraalvmApplication:na\]
at [email protected]/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'
}
CodePudding user response:
This is due to missing metadata for the Jakarta Servlet API; the native image is trying to load a resource bundle that was not included in the native image at build time.
I've submitted a PR to fix that in the GraalVM metadata repository.
In the meantime, you can add the following content to a new file src/main/resources/META-INF/native-image/jakarta.servlet/jakarta.servlet-api/resource-config.json
in your project:
{
"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"
}
}
]
}