0

i have a project that is running in localhost:8080 setting. I am quite new to Heroku and git bash and all of this actually.

I get the following errors when pushing my project to Heroku:

remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/java
remote: -----> Java app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Installing Maven 3.6.2... done
remote: -----> Executing Maven
remote:        $ mvn -DskipTests clean dependency:list install
remote:        [INFO] Scanning for projects...
remote:        [INFO]
remote:        [INFO] -------------------------< tkt:wepa_Projekti >--------------------------
remote:        [INFO] Building wepa_Projekti 1.0-SNAPSHOT
remote:        [INFO] --------------------------------[ jar ]---------------------------------
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/passay/passay/1.6.0/passay-1.6.0.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/passay/passay/1.6.0/passay-1.6.0.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/passay/passay/1.6.0/passay-1.6.0.pom (15 kB at 148 kB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/springframework/boot/spring-boot-starter-validation/2.3.2.RELEASE/spring-boot-starter-validation-2.3.2.RELEASE.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-validation/2.3.2.RELEASE/spring-boot-starter-validation-2.3.2.RELEASE.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-validation/2.3.2.RELEASE/spring-boot-starter-validation-2.3.2.RELEASE.pom (2.5 kB at 121 kB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final.pom (13 kB at 1.0 MB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/hibernate/validator/hibernate-validator-parent/6.1.5.Final/hibernate-validator-parent-6.1.5.Final.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/hibernate/validator/hibernate-validator-parent/6.1.5.Final/hibernate-validator-parent-6.1.5.Final.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/hibernate/validator/hibernate-validator-parent/6.1.5.Final/hibernate-validator-parent-6.1.5.Final.pom (67 kB at 2.0 MB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/jboss/arquillian/arquillian-bom/1.1.11.Final/arquillian-bom-1.1.11.Final.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/jboss/arquillian/arquillian-bom/1.1.11.Final/arquillian-bom-1.1.11.Final.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/jboss/arquillian/arquillian-bom/1.1.11.Final/arquillian-bom-1.1.11.Final.pom (11 kB at 967 kB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/jboss/shrinkwrap/shrinkwrap-bom/1.2.3/shrinkwrap-bom-1.2.3.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/jboss/shrinkwrap/shrinkwrap-bom/1.2.3/shrinkwrap-bom-1.2.3.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/jboss/shrinkwrap/shrinkwrap-bom/1.2.3/shrinkwrap-bom-1.2.3.pom (4.0 kB at 443 kB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/jboss/shrinkwrap/resolver/shrinkwrap-resolver-bom/2.2.0/shrinkwrap-resolver-bom-2.2.0.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/jboss/shrinkwrap/resolver/shrinkwrap-resolver-bom/2.2.0/shrinkwrap-resolver-bom-2.2.0.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/jboss/shrinkwrap/resolver/shrinkwrap-resolver-bom/2.2.0/shrinkwrap-resolver-bom-2.2.0.pom (5.3 kB at 331 kB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-bom/2.0.0-alpha-8/shrinkwrap-descriptors-bom-2.0.0-alpha-8.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-bom/2.0.0-alpha-8/shrinkwrap-descriptors-bom-2.0.0-alpha-8.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-bom/2.0.0-alpha-8/shrinkwrap-descriptors-bom-2.0.0-alpha-8.pom (5.2 kB at 582 kB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.pom
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.pom (11 kB at 1.3 MB/s)
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/ognl/ognl/3.1.12/ognl-3.1.12.jar
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/springframework/boot/spring-boot-starter-validation/2.3.2.RELEASE/spring-boot-starter-validation-2.3.2.RELEASE.jar
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final.jar
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar
remote:        [INFO] Downloading from tmc: https://maven.mooc.fi/releases/org/passay/passay/1.6.0/passay-1.6.0.jar
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/passay/passay/1.6.0/passay-1.6.0.jar
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-validation/2.3.2.RELEASE/spring-boot-starter-validation-2.3.2.RELEASE.jar
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final.jar
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/ognl/ognl/3.1.12/ognl-3.1.12.jar
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-validation/2.3.2.RELEASE/spring-boot-starter-validation-2.3.2.RELEASE.jar (4.8 kB at 58 kB/s)
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/ognl/ognl/3.1.12/ognl-3.1.12.jar (236 kB at 2.1 MB/s)
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/passay/passay/1.6.0/passay-1.6.0.jar (124 kB at 1.1 MB/s)
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar (92 kB at 760 kB/s)
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/hibernate/validator/hibernate-validator/6.1.5.Final/hibernate-validator-6.1.5.Final.jar (1.3 MB at 5.7 MB/s)
remote:        [INFO]
remote:        [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ wepa_Projekti ---
remote:        [INFO]
remote:        [INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ wepa_Projekti ---
remote:        [INFO]
remote:        [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ wepa_Projekti ---
remote:        [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote:        [INFO] Copying 4 resources
remote:        [INFO] Copying 21 resources
remote:        [INFO]
remote:        [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ wepa_Projekti ---
remote:        [INFO] Changes detected - recompiling the module!
remote:        [INFO] Compiling 44 source files to /tmp/build_b0fadb36/target/classes
remote:        [INFO] /tmp/build_b0fadb36/src/main/java/projekti/CustomErrorController.java: /tmp/build_b0fadb36/src/main/java/projekti/CustomErrorController.java uses or overrides a deprecated API.
remote:        [INFO] /tmp/build_b0fadb36/src/main/java/projekti/CustomErrorController.java: Recompile with -Xlint:deprecation for details.
remote:        [INFO] -------------------------------------------------------------
remote:        [ERROR] COMPILATION ERROR :
remote:        [INFO] -------------------------------------------------------------
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/SaunojaService.java:[154,120] cannot find symbol
remote:          symbol:   method isBlank()
remote:          location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/NotificationService.java:[54,81] cannot find symbol
remote:          symbol:   method isBlank()
remote:          location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/MessageService.java:[82,71] cannot find symbol
remote:          symbol:   method isBlank()
remote:          location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/CommentService.java:[56,71] cannot find symbol
remote:          symbol:   method isBlank()
remote:          location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/AccountFreezeService.java:[71,51] cannot find symbol
remote:          symbol:   method isBlank()
remote:          location: class java.lang.String
remote:        [INFO] 5 errors
remote:        [INFO] -------------------------------------------------------------
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD FAILURE
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  12.772 s
remote:        [INFO] Finished at: 2021-08-18T14:35:20Z
remote:        [INFO] ------------------------------------------------------------------------
remote:        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project wepa_Projekti: Compilation failure: Compilation failure:
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/SaunojaService.java:[154,120] cannot find symbol
remote:        [ERROR]   symbol:   method isBlank()
remote:        [ERROR]   location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/NotificationService.java:[54,81] cannot find symbol
remote:        [ERROR]   symbol:   method isBlank()
remote:        [ERROR]   location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/MessageService.java:[82,71] cannot find symbol
remote:        [ERROR]   symbol:   method isBlank()
remote:        [ERROR]   location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/CommentService.java:[56,71] cannot find symbol
remote:        [ERROR]   symbol:   method isBlank()
remote:        [ERROR]   location: class java.lang.String
remote:        [ERROR] /tmp/build_b0fadb36/src/main/java/projekti/AccountFreezeService.java:[71,51] cannot find symbol
remote:        [ERROR]   symbol:   method isBlank()
remote:        [ERROR]   location: class java.lang.String
remote:        [ERROR] -> [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/MojoFailureException
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/

My Java version:

$ java -version
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode)

It seems that the problem could be with the dependencies of the project, but what i don't understand is, that why would the problem not occur locally.

Project 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 
                             http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>tkt</groupId>
    <artifactId>wepa_Projekti</artifactId>
    <name>wepa_Projekti</name>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.2.RELEASE</version>
        <relativePath/>
    </parent>

    <dependencies>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-java8time</artifactId>
            <version>3.0.4.RELEASE</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>        
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.passay</groupId>
            <artifactId>passay</artifactId>
            <version>1.6.0</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.fluentlenium</groupId>
            <artifactId>fluentlenium-junit</artifactId>
            <version>3.7.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.fluentlenium</groupId>
            <artifactId>fluentlenium-assertj</artifactId>
            <version>3.7.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>htmlunit-driver</artifactId>
        </dependency>  
                        
        <!-- TMC -->
        <dependency>
            <groupId>fi.helsinki.cs.tmc</groupId>
            <artifactId>edu-test-utils</artifactId>
            <version>0.4.2</version>
            <scope>test</scope>
        </dependency>
    
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>tmc</id>
            <name>TMC repo</name>
            <url>https://maven.mooc.fi/releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>tmc</id>
            <name>TMC repo</name>
            <url>https://maven.mooc.fi/releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>
mortar-1
  • 97
  • 7
  • 1
    I can see above that you've installed JDK 1.8. This version does not have `isBlank()`. You need at least Java 11 for that. It's possible that heroku is using a different version than the command line so you should check for that. – markspace Aug 18 '21 at 15:05
  • Thanks for the fast answer! I truly seems to install the 1.8 version. But why? Can it be the maven.compiler.source and .target that are 1.8 that causes this? – mortar-1 Aug 18 '21 at 15:09
  • I would say so. Have you tested changing it to Java 11? – João Dias Aug 18 '21 at 15:37
  • 1
    The [Heroku documentation](https://devcenter.heroku.com/articles/java-support#supported-java-versions) states that you should add a file "system.properties" that specifies the required Java version that Heroku should use: "java.runtime.version=11" – Thomas Kläger Aug 18 '21 at 15:44
  • Hello, and thanks again for the commments. I tried changing the maven.compiler.source and .target to 1.11, and later to 11. Both gave a new error: "Fatal error compiling: invalid target release: 11(or 1.11)". Also adding the system.properties file with the line mentioned by Thomas did not change the installed JDK version from 1.8 while pushing to Herkoku. – mortar-1 Aug 20 '21 at 02:09
  • I found a poor soul facing a similar problem here, but he's problem was found when checking "echo %JAVA_HOME%" and finding that a different version of JDK was comming up there., but mine shows jdk-11. I also tried checking "mvn --version" and the result there is too "Java version: 11.0.9.1." – mortar-1 Aug 20 '21 at 02:10
  • Very strange. I just checked out the heroku sample application, changed the system.properties file there to read "java.runtime.version=11", added the change using `git add .`, commited with `git commit -m "Java11"` and then pushed it with `git push heroku master`. For me this was sufficient to change to Java version from 8 to 11. – Thomas Kläger Aug 20 '21 at 14:03
  • Yes I made an answer here below about it. My problem was that I created the system.properties file to the resources folder with the application.properties files. When moving the file to the root, it worked for me too. – mortar-1 Aug 22 '21 at 07:09

2 Answers2

0

I can't comment so I'm leaving this as an answer:

It seems that you're using Java 11+ features on a Java 1.8 release. Make sure your IDE can use a Java 11 JDK (look up how to set this up here for example in Eclipse).

Then, in your .pom file, change:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

to:

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

This will make Maven compile your project to Java 11 instead of Java 8. Maybe you need to update your Maven version so it can recognize Java 11 correctly.

fiftyone_51
  • 105
  • 7
  • I tried all this. When changing maven.compiler.source and .target to 11 i get a new error: "Fatal error compiling: invalid target release: 11". I'm just about to come up with a java 1.8 way to do isBlank().. witch is a pitty :( – mortar-1 Aug 20 '21 at 02:41
  • When checking "mvn --version" i get: Apache Maven 3.8.1 and Java verison 11.0.9.1 – mortar-1 Aug 20 '21 at 02:43
  • Do you use mvn command line tool to compile or do you use an IDE like Eclipse? – fiftyone_51 Aug 20 '21 at 02:45
  • The output of `mvn --version` is irrelevant if you use an IDE. Make sure to configure your IDE properly to use the Java 11 JDK – fiftyone_51 Aug 20 '21 at 02:52
  • Im using Netbeans locally and everything works fine. But when pushing to Heroku with Git Bash, the errors occure. – mortar-1 Aug 20 '21 at 03:49
0

I'm sorry to inform, but there was an almost identical question with a working answer by Muhammad Shah : Heroku cannot deploy Java 11 Spring Boot App.

The answer still was the same that Thomas Kläger gave here. My mistake was that I had created the system.proterties file in the resources folder, but it should have been situated in the root.

Thanks for all of you who answered and commented!

mortar-1
  • 97
  • 7