2

Please help to deploy my application on Heroku. Getting error message from Heroku *

"Application Error. An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details."

Here log from Heroku:

2016-07-21T22:11:30.966800+00:00 heroku[slug-compiler]: Slug compilation 
started 2016-07-21T22:11:30.773385+00:00 heroku[api]: Release v8 created by 
zzheads@gmail.com 2016-07-21T22:11:56.184847+00:00 heroku[router]: at=error 
code=H14 desc="No web processes running" method=GET path="/favicon.ico" 
host=zzheads-countries.herokuapp.com request_id=a03c9276-b038-4f9f-8e6d-
5f29f14b441 fwd="5.3.141.153" dyno= connect= service= status=503 bytes=

My gradle build file:

group 'com.zzheads'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath  'org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE'
    }
}

apply plugin: 'java'
apply plugin: 'spring-boot'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
}

task stage {
    dependsOn build
}

And my Proc file:

web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/countries-1.0-SNAPSHOT.jar
zzheads
  • 1,368
  • 5
  • 28
  • 57

2 Answers2

3

Your build probably generates an executable JAR file in the directory build/libs. Try this in your Procfile:

web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/countries-1.0-SNAPSHOT.jar

You can test it locally by running:

$ ./gradlew stage
$ heroku local
codefinger
  • 10,088
  • 7
  • 39
  • 51
  • Same error message, same logs. Tryed test it locally: E:\Projects\countries>gradlew stage :clean :compileJava :processResources :classes :jar :findMainClass :startScripts :installApp The installApp task has been deprecated and is scheduled to be removed in Gradle 3.0. Please use the installDist task instead. :stage BUILD SUCCESSFUL Total time: 5.13 secs E:\Projects\countries>heroku local [WARN] No ENV file found 12:04:46 web.1 | Error: Could not find or load main class $JAVA_OPTS [DONE] Killing all processes with signal null 12:04:46 web.1 Exited with exit code 1 – zzheads Jul 22 '16 at 09:05
  • The error about `$JAVA_OPTS` is because you are on windows. you'll need to create a `Procfile.windows` with a windows formatted command and run `heroku local -f Procfile.windows` – codefinger Jul 22 '16 at 12:51
  • Have you tried it on Heroku? you will probably have to run `heroku ps:scale web=1` to get the app up now that it's crashed. – codefinger Jul 22 '16 at 12:52
  • Yes, I've tryed this on Heroku as wrote above. Getting same error, same logs. How I can test it locally? gradlew stage -> Build successfull, but "heroku local" runs with errors – zzheads Jul 22 '16 at 13:28
0

I think that Heroku is not able to find your .jar because when it does not find a version property, the gradle buildpack just uses its own build id. So your .jar is not found under the filename in your procfile. You can set the following:

jar{
  baseName = 'countries-'
  version = '1.0-SNAPSHOT'
} 

so Heroku picks up on those variables. Note that if you're using Spring Boot 2.*, the plugin disables the jar tasks, and adds a bootJar task on which you then have to set these to variables.

With that, the platform should be able to find your artifact just fine.

Also, running heroku logs -a <your-app-name-here> -t you'll get some more information about the status of your app while debugging

thomi
  • 1,603
  • 1
  • 24
  • 31