bootBuildImage fails if BP_NATIVE_IMAGE is true
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Expected Behavior
Running native docker image should work correctly like non-native image.
### Actual Behaviour
When activating native image via the `bootBuildImage` closure in `build.gradle`:
```groovy
bootBuildImage {
verboseLogging = true
environment = [
"BP_NATIVE_IMAGE": "true",
"BP_JVM_VERSION": "24",
]
}
```
Docker run always fails:
```bash
❯ docker run --rm --network="host" test:0.1
java.io.IOException: Stream closed
at java.base@24.0.1/java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:170)
at java.base@24.0.1/java.io.BufferedInputStream.fill(BufferedInputStream.java:289)
at java.base@24.0.1/java.io.BufferedInputStream.read1(BufferedInputStream.java:330)
at java.base@24.0.1/java.io.BufferedInputStream.read(BufferedInputStream.java:388)
at java.base@24.0.1/java.io.DataInputStream.readFully(DataInputStream.java:213)
at java.base@24.0.1/java.io.DataInputStream.readUnsignedShort(DataInputStream.java:346)
at java.base@24.0.1/java.io.DataInputStream.readUTF(DataInputStream.java:580)
at java.base@24.0.1/java.io.DataInputStream.readUTF(DataInputStream.java:555)
at org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord.loadDgmInfo(GeneratedMetaMethod.java:200)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:207)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:116)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:94)
at groovy.lang.GroovySystem.(GroovySystem.java:37)
at org.codehaus.groovy.runtime.InvokerHelper.(InvokerHelper.java:71)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.createMap(ScriptBytecodeAdapter.java:641)
at grails.util.BuildSettings.(BuildSettings.groovy)
at test.Application.(Application.groovy)
at java.base@24.0.1/java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:328)
at java.base@24.0.1/java.lang.invoke.DirectMethodHandle.internalMemberNameEnsureInit(DirectMethodHandle.java:341)
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.codehaus.groovy.runtime.InvokerHelper.(InvokerHelper.java:71)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.createMap(ScriptBytecodeAdapter.java:641)
at grails.util.BuildSettings.(BuildSettings.groovy)
at test.Application.(Application.groovy)
at java.base@24.0.1/java.lang.invoke.DirectMethodHandle.ensureInitialized(DirectMethodHandle.java:328)
at java.base@24.0.1/java.lang.invoke.DirectMethodHandle.internalMemberNameEnsureInit(DirectMethodHandle.java:341)
Caused by: java.lang.NullPointerException
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:122)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:94)
at groovy.lang.GroovySystem.(GroovySystem.java:37)
... 6 more
```
Note: I could compile the native image to fails later, but the process is complex.
### Steps To Reproduce
1. Start docker: `sudo systemctl restart docker`
2. Download the test application
3. Build the native image: `./gradlew bootBuildImage`
4. run the native image: `docker run --rm --network="host" test:0.1`
Things fails with a IOException...
[test.zip](https://github.com/user-attachments/files/20873044/test.zip)
### Environment Information
```bash
❯ uname -a
Linux cachyos-x8664 6.15.3-2-cachyos #1 SMP PREEMPT_DYNAMIC Thu, 19 Jun 2025 15:58:12 +0000 x86_64 GNU/Linux
❯ ~/.jdks/openjdk-24.0.1/bin/java -fullversion
openjdk full version "24.0.1+9-30"
```
### Example Application
[test.zip](https://github.com/user-attachments/files/20873044/test.zip)
### Version
7.0.0-SNAPSHOT
Contributor guide
Research direction
Start with the attached test application and its build.gradle bootBuildImage configuration, then run ./gradlew bootBuildImage and docker run using the reported Java 24 environment. Trace the native image startup failure shown in the Groovy stack trace; done means the generated Docker image starts successfully with BP_NATIVE_IMAGE=true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, groovy, java
- Domain
- backend, build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100