Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Your project is using Java 17 but the base image is for Java 11 #3704

Closed
nyxz opened this issue Jul 5, 2022 · 3 comments
Closed

Your project is using Java 17 but the base image is for Java 11 #3704

nyxz opened this issue Jul 5, 2022 · 3 comments

Comments

@nyxz
Copy link

nyxz commented Jul 5, 2022

Environment:

  • Jib version: 3.2.1
  • Build tool: Gradle 7.3.1
  • OS: Linux Fedora 33

Description of the issue:
When I run ./gradlew -Pprod bootJar jib I get the following error:
Your project is using Java 17 but the base image is for Java 11, perhaps you should configure a Java 17-compatible base image using the 'jib.from.image' parameter, or set targetCompatibility = 11 or below in your build configuration

Expected behavior:
The image should build with Java 17.

Steps to reproduce:

  1. Create a Spring project with Java 17 and Gradle
  2. Configure just the jib.to.image (without custom jib.from.image).
  3. Run ./gradlew bootJar jib

jib-gradle-plugin Configuration:

jib {
    to {
        image = '<accountId>.dkr.<region>.amazonaws.com/<name>'
        credHelper = 'ecr-login'
    }
}

Log output:

...
> Task :compileJava
Note: Hibernate JPA 2 Static-Metamodel Generator 5.6.4.Final

> Task :jib FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jib'.
> Your project is using Java 17 but the base image is for Java 11, perhaps you should configure a Java 17-compatible base image using the 'jib.from.image' parameter, or set targetCompatibility = 11 or below in your build configuration

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3.1/userguide/command_line_interface.html#sec:command_line_warnings

Additional Information:
I'm using the default JHipster setup and trying to push to AWS ECR. Based on the #3483 I assume I shouldn't make any more configurations. I guess I can workaround by providing custom jib.from.image.

@chanseokoh
Copy link
Member

According to this article, it sounds like JHipster currently uses Java 11 and you need to do some work to upgrade to Java 17.

For Jib, at least I see that they explicitly configure a Java 11 base image in gradle/docker.gradle. Try updating the config.

    from {
        image = "eclipse-temurin:11-jre-focal"
    }

@nyxz
Copy link
Author

nyxz commented Jul 5, 2022

Yep, in order to use Java 17 and not 11 I just changed the target Java version to 17 and it started the app. I totally missed the docker.gradle config. Thank you and apologies for wasting your time. This solves my issue.

@nyxz nyxz closed this as completed Jul 5, 2022
@declanTreanor
Copy link

@nyxz I'm stuck on a similar problem. Can you please spell out, as though I were six, what needs to be changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants