1
  1. When I run the following command:

    git push heroku master
    
  2. I get the following error:

    remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar (21 kB at 1.1 MB/s)
    remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-api/2.8.4/plexus-compiler-api-2.8.4.jar (27 kB at 404 kB/s)
    remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar (317 kB at 4.0 MB/s)
    remote: [INFO] Changes detected - recompiling the module!
    remote: [INFO] Compiling 4 source files to /tmp/build_ca81690e12aa9ecc064d62f3524c8370/target/classes 
    remote: [INFO] ------------------------------------------------------------------------
    remote: [INFO] BUILD FAILURE
    remote: [INFO] ------------------------------------------------------------------------
    remote: [INFO] Total time: 11.868 s
    remote: [INFO] Finished at: 2020-06-03T12:05:45Z
    remote: [INFO] ------------------------------------------------------------------------
    remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project coronavirus-tracker: Fatal error compiling: invalid target release: 12 -> [Help 1]
    remote: [ERROR]
    remote: [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    remote: [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    remote: [ERROR]
    remote: [ERROR] For more information about the errors and possible solutions, please read the following articles:
    remote: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    remote:
    remote: ! ERROR: Failed to build app with Maven
    remote: We're sorry this build is failing! If you can't find the issue in application code,
    remote: please submit a ticket so we can help: https://help.heroku.com/
    remote:
    remote: ! Push rejected, failed to compile Java app.
    remote: 
    remote: ! Push failed
    remote: Verifying deploy...
    remote: 
    remote: ! Push rejected to covid2020global. 
    remote: To https://git.heroku.com/covid2020global.git
    

UPDATE:

Maven pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>io.javabrains</groupId>
    <artifactId>coronavirus-tracker</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>coronavirus-tracker</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>12</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-csv</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!--plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <appName>coronavirus-tracker-master</appName>
                </configuration>
            </plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>12</release>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
4
  • The part reg. the plugin description heroku-maven-plugin has been commented out. Might that be relevant? Also, is it possible for you to build locally, and if so, does it locally build successfully or not? Commented Jun 3, 2020 at 12:39
  • 1
    No it’s not due to plagin and locally I’m getting error while building(mvn clean install). I just realized that I’ve had been using JRE 8, whereas the project requires at least JDK 12. Commented Jun 3, 2020 at 12:41
  • If you have succeeded solved the problem yourself, you can help the community (and maybe get points) by writing out the answer yourself and accept it as the answer. Commented Jun 3, 2020 at 12:44
  • 1
    No, I haven’t solved the problem yet. But I will write the solution here asap! Commented Jun 3, 2020 at 13:36

2 Answers 2

1

The problem is the Java version number. In the error text it says "Fatal error compiling: invalid target release: 12".
For Heroku, you need to create the file "system.properties" in the root of the project, write "java.runtime.version = 12" in it.

The system.properties file indicates which version of Java is being used. Heroku supports many different versions of Java and version "12" is not the default version. Details in the documentation: https://devcenter.heroku.com/articles/getting-started-with-java#declare-app-dependencies https://devcenter.heroku.com/articles/java-support#specifying-a-java-version

Sign up to request clarification or add additional context in comments.

1 Comment

I'm getting error when building the project(mvn clean install)!
1

I finally solved the problem with deleting path to JRE of Java 8. And after that maven finally found path to JDK 13. I checked that with this command mvn -v. After those manipulations I succesfully deployed my project to Heroku!

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.