0

I have a standard Springboot application written with Java 16. This compiles and builds just fine in my IDE and via CI/CD etc.

However, attempting to move the building to a docker file and I'm hit with:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Cannot invoke "javax.tools.JavaCompiler.getStandardFileManager(javax.tools.DiagnosticListener, java.util.Locale, java.nio.charset.Charset)" because "this.delegate" is null

I assume this is some under the hood thing but I can't figure out how to resolve it. I've tried different Gradle images with different builds of the JVM (Hotspot, OpenJ9) but all have the same result.

FROM gradle:jre16-hotspot AS build

COPY --chown=gradle:gradle . /home/gradle/srcn

WORKDIR /home/gradle/src

RUN gradle build

Nothing fancy in my Dockerfile either. I'd love to understand why I only get this issue when building via Docker, and not when building in any other manner.

Any tips?

2
  • What if you try jdk image, not jre? Commented Jul 13, 2021 at 7:57
  • :faceplam: I completely missed that somehow, you're of course correct. Appreciate it! Feel free to switch it to an answer and I'll happily accept. Commented Jul 13, 2021 at 8:15

1 Answer 1

2

Since the compiler is available only in JDK, you need to replace the first line in your Dockerfile with:

FROM gradle:jdk16-hotspot AS build
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.