2

I'm receiving the code error H10 for my deploy, when i try to access it. I read that this happens because i have to set a dynamic port to the application. I've tried all the configurations presented on Heroku's devcenter but with no lucky.

Here is my pom.xml:

`   


<groupId>dogbook</groupId>
        <artifactId>dog-book</artifactId>
        <version>1.0</version>
        <packaging>jar</packaging>

        <name>dog-book</name>
        <description>Dog Book Backend</description>

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.4.RELEASE</version>
            <relativePath />
        </parent>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
            <start-class>br.dogbook.Application</start-class>
            <full-artifact-name>target/${project.artifactId}-${project.version}.jar</full-artifact-name>
        </properties>

        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>io.jsonwebtoken</groupId>
                <artifactId>jjwt</artifactId>
                <version>0.7.0</version>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <optional>true</optional>
            </dependency>

            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-jackson-provider</artifactId>
                <version>1.1.GA</version>
                <scope>compile</scope>
            </dependency>

        </dependencies>

        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>build-info</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <configuration>
                        <dotGitDirectory>../.git</dotGitDirectory>
                    </configuration>
                </plugin>

                <plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>1.2.2</version>
                <configuration>
                    <appName>dog-book</appName>
                    <includeTarget>false</includeTarget>
                    <includes>
                        <include>${basedir}/${full-artifact-name}</include>
                    </includes>
                    <jdkVersion>1.8</jdkVersion>
                    <processTypes>
                        <web>java $JAVA_OPTS -jar ${full-artifact-name}</web>
                    </processTypes>
                </configuration>
            </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>copy</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>com.github.jsimone</groupId>
                                        <artifactId>webapp-runner</artifactId>
                                        <version>8.5.11.3</version>
                                        <destFileName>webapp-runner.jar</destFileName>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
`

And my main/resources/application.yml:

`
server:
   port: 8080

---
  spring:
     profiles: heroku
  server:
    port: ${PORT}
`

That's the complete error: (UPDATED)

`

2017-10-25T04:22:38.012290+00:00 heroku[web.1]: State changed from starting to crashed
    2017-10-25T09:51:04.226590+00:00 heroku[web.1]: State changed from crashed to starting
    2017-10-25T09:51:06.553784+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=44562 -jar target/dog-book-1.0.jar`
    2017-10-25T09:51:07.883843+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
    2017-10-25T09:51:07.884774+00:00 app[web.1]: Error: Unable to access jarfile target/dog-book-1.0.jar
    2017-10-25T09:51:07.966920+00:00 heroku[web.1]: State changed from starting to crashed
    2017-10-25T09:51:07.954716+00:00 heroku[web.1]: Process exited with status 1
    2017-10-25T10:50:16.461375+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dog-book.herokuapp.com request_id=945fe406-6784-4a03-8ec3-cd997da8b023 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https
    2017-10-25T10:50:17.185622+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dog-book.herokuapp.com request_id=01ce7010-cd8d-49f1-a039-f628f0e8e829 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https
    2017-10-25T11:02:09.761721+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dog-book.herokuapp.com request_id=035c33ce-0340-4695-9c46-0f825bf20a24 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https
    2017-10-25T11:02:10.575906+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dog-book.herokuapp.com request_id=a52d39bb-f402-4fec-b2f4-9c6888893706 fwd="189.34.55.2" dyno= connect= service= status=503 bytes= protocol=https

`

I've already configured the Procfile with no extension as well.

web: $JAVA_OPTS -Dserver.port=$PORT -jar target/dog-book-1.0.jar

And still the same.

Any ideas ?

Emmanuel
  • 109
  • 1
  • 9

2 Answers2

4

Unlike the war used default by heroku, the jar is not listening on the same port Heroku is checking for availability.

See https://exampledriven.wordpress.com/2016/11/04/spring-boot-heroku-example/

The trick to add --server.port=$PORT to Procfile did not work for me.

but adding server.port=${PORT:8080} to Spring's application.properties was picked up and worked perfectly!

Eddie
  • 9,696
  • 4
  • 45
  • 58
0

Error log is not complete. Visit herokuapp.com login with your account. You will see complete log. Share that log here. Also you should check Java version and DB connection. Most of the time jdbc driver registration is main reason.

  • Fix your Procfile like this web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war – Umesh Kumar Sharma Oct 25 '17 at 12:13
  • After updating your Procfile; if it does not works. I recommend you to create simple Maven web project. I have built my app without spring boot. It is working fantastic. – Umesh Kumar Sharma Oct 25 '17 at 12:21