2

I am deploying spring boot app on heroku using gitlab ci/cd

i am using spring boot 3.0.0 and java 17

Anyone knows how to fix it? Also on line 8 it's -----> Installing OpenJDK 1.8... done i don't know why and how even i have java 17 in app

Deploying application
uploading application archive
triggering new deployment
-----> Building on the Heroku-22 stack
-----> Determining which buildpack to use for this app
-----> Gradle app detected
-----> Spring Boot detected
-----> Installing OpenJDK 1.8... done
-----> Building Gradle app...
-----> executing ./gradlew build -x check
       Downloading https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
       ...........10%............20%...........30%............40%...........50%............60%...........70%............80%...........90%............100%
       To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.5.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
       Daemon will be stopped at the end of the build 
       
       FAILURE: Build failed with an exception.
       
       * What went wrong:
       A problem occurred configuring root project 'auth'.
       > Could not resolve all files for configuration ':classpath'.
          > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.0.
            Required by:
                project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.0
             > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.0 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5.1' but:
                 - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a library, packaged as a jar, and its dependencies declared externally:
                     - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 8
                     - Other compatible attribute:
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
                 - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a component, and its dependencies declared externally:
                     - Incompatible because this component declares documentation and the consumer needed a library
                     - Other compatible attributes:
                         - Doesn't say anything about its target Java version (required compatibility with Java 8)
                         - Doesn't say anything about its elements (required them packaged as a jar)
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
                 - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.0 declares a library, packaged as a jar, and its dependencies declared externally:
                     - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 8
                     - Other compatible attribute:
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
                 - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
                     - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
                     - Other compatible attribute:
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
                 - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
                     - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
                     - Other compatible attribute:
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
                 - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a component, and its dependencies declared externally:
                     - Incompatible because this component declares documentation and the consumer needed a library
                     - Other compatible attributes:
                         - Doesn't say anything about its target Java version (required compatibility with Java 8)
                         - Doesn't say anything about its elements (required them packaged as a jar)
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
       
       * 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
       
       BUILD FAILED in 9s
 !     ERROR: Failed to run Gradle!
       We're sorry this build is failing. If you can't find the issue in application
       code, please submit a ticket so we can help: https://help.heroku.com
       You can also try reverting to the previous version of the buildpack by running:
       $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version
       
       Thanks,
       Heroku
Andrej Istomin
  • 2,527
  • 2
  • 15
  • 22
noBoom
  • 127
  • 2
  • 9
  • You are using Java8 **not** Java17 as you can see from the output. Spring Boot 3 has as a minimum requirement Java17, so you must use at least java 17 or higher. – M. Deinum Nov 28 '22 at 08:43
  • Why is this that you keep posting the same question under different guises? https://stackoverflow.com/q/74586031/839733 – Abhijit Sarkar Nov 29 '22 at 01:57
  • Hi, for me it was spring boot 3 causing the issue, if you are not very keen about it , try using spring 2.7.6 or some older version – Harsh Dec 08 '22 at 11:35

1 Answers1

3

You may be using Java 17 locally, but on Heroku you're using Java 8. This is the default:

Heroku currently uses OpenJDK 8 to run your application by default. Other OpenJDK versions are also available. Depending on the OpenJDK version you select the latest available version of that JDK will be used each time you deploy your app.

You need to explicitly request the correct version of Java. Add a file called system.properties to the root directory of your project that contains

java.runtime.version=17

then commit and redeploy.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257