Heroku Deploy of Java app fails using Ant Buildpack - java

I'm trying to deploy the following app to Heroku:
https://github.com/raeffu/ch.bfh.bti7081.s2015.Blue/
I'm using the Ant Buildpack.
After executing
$ git push heroku master
the build is successful and then this error message appears at the end of the log:
remote: BUILD SUCCESSFUL
[.....]
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing... done, 236.4MB
remote: -----> Launching... failed
remote:
remote: ! Push rejected, failure creating release
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to healvis.
remote:
To https://git.heroku.com/healvis.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/healvis.git'
The Procfile looks like this:
web: java -jar lib/webapp-runner-8.0.18.0-M1.jar --expand-war --port $PORT target/healvis.war
The log does not reveal any helpful information.
How can I find out more what's going wrong or, even better, how can I fix it?

The problem was the addon shared-database required by the buildpack.
I forked the repository and removed the addon, now it works.

Related

I am trying automatic deploy to Heroku using GitHub actions for java Gradle app (SpringBoot) but getting error every time

Getting this error: Error: Command failed: git push heroku main:refs/heads/main --force
.yml file for GitHub Actions
name: Java CI
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Set up JDK 17
uses: actions/setup-java#v3
with:
java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action#e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Build with Gradle
uses: gradle/gradle-build-action#0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: build
- uses: akhileshns/heroku-deploy#v3.12.12 # This is the action
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: "all-books-store" #Must be unique in Heroku
heroku_email: "mail-id-here"
branch: "main"
At first GitHub branch was set to master. I thought there could be a issue with it so renamed it to main and changed the branch. But still the issue was same. Before deployment everything goes good in GitHub actions build but during build it gets rejected and shows the error.
Procfile
web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/demo-0.0.1-SNAPSHOT.jar
Code run while it is deploying using github actions
Run akhileshns/heroku-deploy#v3.12.12
Created and wrote to ~/.netrc
Successfully logged into heroku
› Warning: Our terms of service have changed:
Added git remote heroku
› https://dashboard.heroku.com/terms-of-service
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Gradle app detected
remote: -----> Spring Boot detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x check
remote: Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
remote: ...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
remote: To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
remote: Daemon will be stopped at the end of the build
remote: > Task :compileJava FAILED
remote:
remote: FAILURE: Build failed with an exception.
remote:
remote: * What went wrong:
remote: Execution failed for task ':compileJava'.
remote: > invalid source release: 17
remote:
remote: * Try:
remote: > Run with --stacktrace option to get the stack trace.
remote: > Run with --info or --debug option to get more log output.
remote: > Run with --scan to get full insights.
remote:
remote: * Get more help at https://help.gradle.org
remote:
remote: BUILD FAILED in 24s
remote: 1 actionable task: 1 executed
remote:
remote: ! ERROR: Failed to run Gradle!
remote: We're sorry this build is failing. If you can't find the issue in application
remote: code, please submit a ticket so we can help: https://help.heroku.com
remote: You can also try reverting to the previous version of the buildpack by running:
remote: $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version
remote:
remote: Thanks,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Gradle app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to all-books-store.
remote:
To https://git.heroku.com/all-books-store.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/all-books-store.git'
Unable to push branch because the branch is behind the deployed branch. Using --force to deploy branch.
(If you want to avoid this, set dontuseforce to 1 in with: of .github/workflows/action.yml.
Specifically, the error was: Error: Command failed: git push heroku main:refs/heads/main
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Gradle app detected
remote: -----> Spring Boot detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x check
remote: Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
remote: ...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
remote: To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
remote: Daemon will be stopped at the end of the build
remote: > Task :compileJava FAILED
remote:
remote: FAILURE: Build failed with an exception.
remote:
remote: * What went wrong:
remote: Execution failed for task ':compileJava'.
remote: > invalid source release: 17
remote:
remote: * Try:
remote: > Run with --stacktrace option to get the stack trace.
remote: > Run with --info or --debug option to get more log output.
remote: > Run with --scan to get full insights.
remote:
remote: * Get more help at https://help.gradle.org
remote:
remote: BUILD FAILED in 24s
remote: 1 actionable task: 1 executed
remote:
remote: ! ERROR: Failed to run Gradle!
remote: We're sorry this build is failing. If you can't find the issue in application
remote: code, please submit a ticket so we can help: https://help.heroku.com
remote: You can also try reverting to the previous version of the buildpack by running:
remote: $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version
remote:
remote: Thanks,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Gradle app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to all-books-store.
remote:
To https://git.heroku.com/all-books-store.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/all-books-store.git'
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Gradle app detected
remote: -----> Spring Boot detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x check
remote: Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
remote: ...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
remote: To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
remote: Daemon will be stopped at the end of the build
remote: > Task :compileJava FAILED
remote:
remote: FAILURE: Build failed with an exception.
remote:
remote: * What went wrong:
remote: Execution failed for task ':compileJava'.
remote: > invalid source release: 17
remote:
remote: * Try:
remote: > Run with --stacktrace option to get the stack trace.
remote: > Run with --info or --debug option to get more log output.
remote: > Run with --scan to get full insights.
remote:
remote: * Get more help at https://help.gradle.org
remote:
remote: BUILD FAILED in 23s
remote: 1 actionable task: 1 executed
remote:
remote: ! ERROR: Failed to run Gradle!
remote: We're sorry this build is failing. If you can't find the issue in application
remote: code, please submit a ticket so we can help: https://help.heroku.com
remote: You can also try reverting to the previous version of the buildpack by running:
remote: $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version
remote:
remote: Thanks,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Gradle app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 04b91247a117524163405aa40742f4bd84afb3fc
remote: !
remote: ! We have detected that you have triggered a build from source code with version 04b91247a117524163405aa40742f4bd84afb3fc
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
Error: Error: Command failed: git push heroku main:refs/heads/main --force
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Gradle app detected
remote: -----> Spring Boot detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x check
remote: Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
remote: ...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
remote: To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
remote: Daemon will be stopped at the end of the build
remote: > Task :compileJava FAILED
remote:
remote: FAILURE: Build failed with an exception.
remote:
remote: * What went wrong:
remote: Execution failed for task ':compileJava'.
remote: > invalid source release: 17
remote:
remote: * Try:
remote: > Run with --stacktrace option to get the stack trace.
remote: > Run with --info or --debug option to get more log output.
remote: > Run with --scan to get full insights.
remote:
remote: * Get more help at https://help.gradle.org
remote:
remote: BUILD FAILED in 23s
remote: 1 actionable task: 1 executed
remote:
remote: ! ERROR: Failed to run Gradle!
remote: We're sorry this build is failing. If you can't find the issue in application
remote: code, please submit a ticket so we can help: https://help.heroku.com
remote: You can also try reverting to the previous version of the buildpack by running:
remote: $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version
remote:
remote: Thanks,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Gradle app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 04b91247a117524163405aa40742f4bd84afb3fc
remote: !
remote: ! We have detected that you have triggered a build from source code with version 04b91247a117524163405aa40742f4bd84afb3fc
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to all-books-store.
remote:
To https://git.heroku.com/all-books-store.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/all-books-store.git'
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to all-books-store.
remote:
To https://git.heroku.com/all-books-store.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/all-books-store.git'
Screenshot for build using GitHub actions.
enter image description here
This has nothing to do with anything except your requirements. Here is the actual error, right in the output you quoted:
remote: * What went wrong:
remote: Execution failed for task ':compileJava'.
remote: > invalid source release: 17
(Why Java 17 is invalid here is a different question that you can ask, but see, e.g., Execution failed for task ':compileJava'. > invalid source release: 1.7 first.)

Error in deploying app to heroku (spring boot)

So what I'm trying to do is to deploy my Spring Boot App to Heroku (using Git and Heroku CLI).
But every time I push my repo to Heroku, these errors appear after I used "$git push heroku master" in my terminal.
remote: [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.2:repackage (repackage) on project UserEditor: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.6.2:repackage failed: Unable to find main class -> [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/PluginExecutionException
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: !
remote: ! ## Warning - The same version of this code has already been built: 33efb1c07b67aebd548c83b47099d3a66a2efed2
remote: !
remote: ! We have detected that you have triggered a build from source code with version 33efb1c07b67aebd548c83b47099d3a66a2efed2
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to myhome-app-1.
remote:
To https://git.heroku.com/myhome-app-1.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myhome-app-1.git' ```
The error would be because you are using Java version above 8 and for free deployment Heroku only allows Java version-8. so in pom.xml change the java version to 8 and rebuild maven. After that, run the project in your local system just to verify there are no errors because Java-8 doesn't contain all the functions that you would have used in your project.

When i try to git push heroku i get an error

Error im getting is below, this happens when i do "git push heroku master"
Enumerating objects: 262, done.
Counting objects: 100% (262/262), done.
Delta compression using up to 4 threads
Compressing objects: 100% (232/232), done.
Writing objects: 100% (262/262), 316.61 KiB | 4.34 MiB/s, done.
Total 262 (delta 34), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Gradle app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew stage
remote: Downloading https://services.gradle.org/distributions/gradle-6.0-all.zip
remote: ......................................................................................................................................
remote: Unzipping /app/tmp/cache/.gradle/wrapper/dists/gradle-6.0-all/cra2s42cvogxluqqpvbc5e9xd/gradle-6.0-all.zip to /app/tmp/cache/.gradle/wrapper/dists/gradle-6.0-all/cra2s42cvogxluqqpvbc5e9xd
remote: Set executable permissions for: /app/tmp/cache/.gradle/wrapper/dists/gradle-6.0-all/cra2s42cvogxluqqpvbc5e9xd/gradle-6.0/bin/gradle
remote:
remote: > Configure project :
remote: fatal: not a git repository (or any parent up to mount point /)
remote: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
remote:
remote: FAILURE: Build failed with an exception.
remote:
remote: * Where:
remote: Build file '/tmp/build_24a75868b111767bf7a04169c852fe43/build.gradle' line: 102
remote:
remote: * What went wrong:
remote: A problem occurred evaluating root project 'XXX-bot'.
remote: > Process 'command 'git'' finished with non-zero exit value 128
remote:
remote: * Try:
remote: 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.
remote:
remote: * Get more help at https://help.gradle.org
remote:
remote: Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
remote: Use '--warning-mode all' to show the individual deprecation warnings.
remote: See https://docs.gradle.org/6.0/userguide/command_line_interface.html#sec:command_line_warnings
remote:
remote: BUILD FAILED in 51s
remote:
remote: ! ERROR: Failed to run Gradle!
remote: We're sorry this build is failing. If you can't find the issue in application
remote: code, please submit a ticket so we can help: https://help.heroku.com
remote: You can also try reverting to the previous version of the buildpack by running:
remote: $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version
remote:
remote: Thanks,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Gradle app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to be-anmusicnew.
remote:
To https://git.heroku.com/XXX
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/XXX.git'
while executing "git ls-files gradle" the following files are listed
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
and my Procfile looks like this
"worker: java -jar target/Bot.jar"
Under the configure project there is an error:
fatal: not a git repository (or any parent up to mount point /)
so he can't push to that.
Try to modify the urlwhere you want to push

Failed deployment with Heroku (npm java)

I am trying to deploy my app through Heroku, which is working perfectly on localhost. Even though I had some troubles installing java module on localhost, I finally did it, thanks to this post: https://github.com/nodejs/node/issues/10289.
Now, I'm getting apparently the same error deploying the app on Heroku, but now I'm not able to fix it. I set even the Java Buildpack, just in case, but it didnt help.
I hope someone could help me!
This is my package.json:
{
"name": "tachology",
"version": "0.0.0",
"main": "server/index.js",
"dependencies": {
"angular": "~1.6.0",
"angular-animate": "~1.6.0",
"angular-aria": "~1.6.0",
"angular-cookies": "~1.6.0",
"angular-resource": "~1.6.0",
"angular-sanitize": "~1.6.0",
"angular-ui-router": "^0.4.2",
"angular-validation-match": "^1.9.0",
"babel-polyfill": "^6.7.2",
"babel-runtime": "^6.6.1",
"bluebird": "^3.3.3",
"body-parser": "^1.13.3",
"cal-heatmap": "^3.6.2",
"composable-middleware": "^0.3.0",
"connect-mongo": "^1.2.1",
"cookie-parser": "^1.3.5",
"core-js": "^2.2.1",
"errorhandler": "^1.4.2",
"express": "^4.13.3",
"express-jwt": "^5.0.0",
"express-session": "^1.11.3",
"fast-json-patch": "^1.0.0",
"font-awesome": ">=4.1.0",
"gridfs": "^1.0.0",
"java": "^0.8.0",
"jquery": "^3.2.1",
"jsonformatter": "^0.6.0",
"jsonwebtoken": "^7.0.0",
"lodash": "^4.6.1",
"lusca": "^1.3.0",
"method-override": "^2.3.5",
"mongoose": "^4.1.2",
"morgan": "~1.7.0",
"multer": "^1.3.0",
"multer-gridfs-storage": "^1.2.2",
"ng-google-charts": "^0.1.3",
"passport": "~0.3.0",
"passport-local": "^1.0.0",
"pug": "2.0.0-beta4",
"serve-favicon": "^2.3.0",
"shrink-ray": "^0.1.3",
"sprint-js": "~0.1.0",
"uikit": "^3.0.0-beta.24"
},
"devDependencies": {
"angular-mocks": "~1.6.0",
"autoprefixer": "^6.0.0",
"babel-core": "^6.6.5",
"babel-eslint": "^6.0.4",
"babel-register": "^6.6.5",
"browser-sync": "^2.8.0",
"bs-fullscreen-message": "^1.0.0",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.6.0",
"eslint": "^2.12.0",
"del": "^2.0.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-env": "^0.4.0",
"gulp-eslint": "^2.0.0",
"gulp-imagemin": "^3.0.1",
"gulp-inject": "^4.0.0",
"gulp-istanbul": "^1.1.1",
"gulp-istanbul-enforcer": "^1.0.3",
"gulp-load-plugins": "^1.0.0-rc.1",
"gulp-mocha": "^2.1.3",
"gulp-node-inspector": "^0.1.0",
"gulp-plumber": "^1.0.1",
"gulp-protractor": "^3.0.0",
"gulp-rev": "^7.0.0",
"gulp-rev-replace": "^0.4.2",
"gulp-sort": "^2.0.0",
"gulp-sourcemaps": "^1.5.2",
"gulp-util": "^3.0.5",
"gulp-watch": "^4.3.5",
"gulp-stylint": "^3.0.0",
"grunt": "^1.0.1",
"grunt-build-control": "^0.7.0",
"isparta": "^4.0.0",
"nodemon": "^1.3.7",
"run-sequence": "^1.1.0",
"lazypipe": "^1.0.1",
"webpack": "^1.12.14",
"webpack-dev-middleware": "^1.5.1",
"webpack-stream": "^3.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"html-webpack-plugin": "^2.16.0",
"html-webpack-harddisk-plugin": "~0.0.2",
"pug-html-loader": "^1.0.8",
"awesome-typescript-loader": "0.17.0",
"ng-annotate-loader": "~0.1.0",
"babel-loader": "^6.2.4",
"css-loader": "^0.24.0",
"file-loader": "^0.9.0",
"imports-loader": "^0.6.5",
"isparta-instrumenter-loader": "^1.0.0",
"isparta-loader": "^2.0.0",
"istanbul-instrumenter-loader": "^0.2.0",
"null-loader": "^0.1.1",
"postcss-loader": "^0.11.1",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.0",
"node-sass": "^3.8.0",
"sass-loader": "^4.0.1",
"karma-webpack": "^1.7.0",
"through2": "^2.0.1",
"open": "~0.0.4",
"istanbul": "1.1.0-alpha.1",
"chai": "^3.2.0",
"sinon": "^1.16.1",
"chai-as-promised": "^5.1.0",
"chai-things": "^0.2.0",
"karma": "~0.13.3",
"karma-firefox-launcher": "^1.0.0",
"karma-script-launcher": "^1.0.0",
"karma-coverage": "^1.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-phantomjs-launcher": "~1.0.0",
"karma-spec-reporter": "~0.0.20",
"karma-sourcemap-loader": "~0.3.7",
"sinon-chai": "^2.8.0",
"mocha": "^3.0.2",
"jasmine-core": "^2.3.4",
"karma-jasmine": "^1.0.2",
"jasmine-spec-reporter": "^2.4.0",
"phantomjs-prebuilt": "^2.1.4",
"proxyquire": "^1.0.1",
"strip-ansi": "^3.0.1",
"supertest": "^1.1.0"
},
"engines": {
"node": "6.2.2",
"npm": "3.9.5"
},
"scripts": {
"test": "gulp test",
"update-webdriver": "node node_modules/protractor/bin/webdriver-manager update",
"start": "node server"
},
"private": true
}
And this is the logs when deploying:
Warning: remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 6.2.2
remote: engines.npm (package.json): 3.9.5
remote:
remote: Resolving node version 6.2.2...
remote: Downloading and installing node 6.2.2...
remote: npm 3.9.5 already installed with node
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (new-signature)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote:
remote: > iltorb#1.3.6 install /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/iltorb
remote: > node-pre-gyp install --fallback-to-build
remote:
remote: [iltorb] Success: "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/iltorb/build/bindings/iltorb.node" is installed via remote
remote:
remote: > node-zopfli#1.4.0 install /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli
remote: > node-pre-gyp install --fallback-to-build
remote:
remote: node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v48-linux-x64.tar.gz
remote: node-pre-gyp ERR! Pre-built binaries not found for node-zopfli#1.4.0 and node#6.2.2 (node-v48 ABI) (falling back to source compile with node-gyp)
remote: make: Entering directory '/tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli/build'
remote: CXX(target) Release/obj.target/zopfli/src/zopfli-binding.o
remote: CXX(target) Release/obj.target/zopfli/src/png/zopflipng.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/blocksplitter.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/cache.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/deflate.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/gzip_container.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/hash.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/katajainen.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/lz77.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/squeeze.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/tree.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/util.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/zlib_container.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/zopfli_lib.o
remote: CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/zopflipng_lib.o
remote: CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/lodepng/lodepng.o
remote: CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/lodepng/lodepng_util.o
remote: SOLINK_MODULE(target) Release/obj.target/zopfli.node
remote: COPY Release/zopfli.node
remote: COPY /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli/lib/binding/node-v48-linux-x64/zopfli.node
remote: TOUCH Release/obj.target/action_after_build.stamp
remote: make: Leaving directory '/tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli/build'
remote:
remote: > java#0.8.0 install /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/java
remote: > node-gyp rebuild
remote:
remote: [node-java] Error: not found: javac
remote: gyp: Call to 'node findJavaHome.js' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
remote: gyp ERR! configure error
remote: gyp ERR! stack Error: `gyp` failed with exit code: 1
remote: gyp ERR! stack at ChildProcess.onCpExit (/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
remote: gyp ERR! stack at emitTwo (events.js:106:13)
remote: gyp ERR! stack at ChildProcess.emit (events.js:191:7)
remote: gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
remote: gyp ERR! System Linux 3.13.0-128-generic
remote: gyp ERR! command "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/bin/node" "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
remote: gyp ERR! cwd /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/java
remote: gyp ERR! node -v v6.2.2
remote: gyp ERR! node-gyp -v v3.3.1
remote: gyp ERR! not ok
remote: tachology#0.0.0 /tmp/build_2beaa787f71f40bc41e528a14b9c399c
remote: ├── angular#1.6.6
remote: ...
remote: ├── sprint-js#0.1.0
remote: └── uikit#3.0.0-beta.30
remote:
remote: npm ERR! Linux 3.13.0-128-generic
remote: npm ERR! argv "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/bin/node" "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.npmrc"
remote: npm ERR! node v6.2.2
remote: npm ERR! npm v3.9.5
remote: npm ERR! code ELIFECYCLE
remote:
remote: npm ERR! java#0.8.0 install: `node-gyp rebuild`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the java#0.8.0 install script 'node-gyp rebuild'.
remote: npm ERR! Make sure you have the latest version of node.js and npm installed.
remote: npm ERR! If you do, this is most likely a problem with the java package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system:
remote: npm ERR! node-gyp rebuild
remote: npm ERR! You can get information on how to open an issue for this project with:
remote: npm ERR! npm bugs java
remote: npm ERR! Or if that isn't available, you can get their info via:
remote: npm ERR! npm owner ls java
remote: npm ERR! There is likely additional logging output above.
remote:
remote: npm ERR! Please include the following file with any support request:
remote: npm ERR! /tmp/build_2beaa787f71f40bc41e528a14b9c399c/npm-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to tachology.
remote:
To https://git.heroku.com/tachology.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/tachology.git'
Use --force to continue.
Aborted due to warnings.
It seems that your node-gyp requires java to be built correctly. The thing with Heroku's architecture is that it only provides you what you specify/need. Right now I don't think Heroku understands that it needs a JVM to run your application. So you should provide a buildpack. A build pack put very simply is a set of rules telling Heroku what to set-up, install and build. There is a buildpack for JVM called heroku/jvm.
So, what you have to do is add this to your application through the dashboard or your CLI via heroku buildpacks:add heroku/jvm.
There is one more thing to do. Since your app requires javac at build time itself, we should pull up the build order for java/jvm . So in that case you should probably do heroku buildpacks:add --index 1 heroku/jvm. This puts the JVM buildpack at position 1 and pushes every other buildpack down the order.
Now when the app starts building, it first sets up the JVM (thus enabling javac for your instance) and then runs the NodeJS build. This build will now pick up the javac from the current instance and build accordingly.
Ref: Mulitple Buildpacks in Heroku

Spring Boot Gradle app on Heroku: Unable to access jarfile

I have a spring boot gradle app which I could run successfully on my PC by doing:
heroku local
It can also deploy on heroku successfully when I go:
git push heroku master
This is my result:
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 596 bytes | 0 bytes/s, done.
Total 9 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching set buildpack https://github.com/heroku/heroku-buildpack-gradle... done
remote: -----> Gradle app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote: WARNING: The Gradle buildpack is currently in Beta.
remote: -----> executing ./gradlew build
remote: :compileJavaNote: Some input files use unchecked or unsafe operations.
remote: Note: Recompile with -Xlint:unchecked for details.
remote:
remote: :processResources
remote: :classes
remote: :jar
remote: :bootRepackage
remote: :assemble
remote: :compileTestJava UP-TO-DATE
remote: :processTestResources UP-TO-DATE
remote: :testClasses UP-TO-DATE
remote: :test UP-TO-DATE
remote: :check UP-TO-DATE
remote: :build
remote:
remote: BUILD SUCCESSFUL
remote:
remote: Total time: 11.935 secs
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing... done, 72.3MB
remote: -----> Launching... done, v9
remote: https://myapp.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/myapp.git
6326429..291326d master -> master
But when I try to access it on heroku, it crashes. The heroku logs says this:
2015-12-11T17:05:46.096985+00:00 heroku[api]: Deploy 291326d by xxx#gmail.com
2015-12-11T17:05:46.097021+00:00 heroku[api]: Release v9 created by xxx#gmail.com
2015-12-11T17:05:46.378258+00:00 heroku[slug-compiler]: Slug compilation started
2015-12-11T17:05:46.378269+00:00 heroku[slug-compiler]: Slug compilation finished
2015-12-11T17:05:46.755655+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-11T17:05:53.121398+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=5000 -jar build/libs/myapp.jar`
2015-12-11T17:05:54.260741+00:00 app[web.1]: Error: Unable to access jarfile build/libs/myapp.jar
2015-12-11T17:05:54.784064+00:00 heroku[web.1]: State changed from starting to crashed
2015-12-11T17:05:54.773714+00:00 heroku[web.1]: Process exited with status 1
2015-12-11T17:05:54.788248+00:00 heroku[web.1]: State changed from crashed to starting
Why is it Unable to access jarfile build/libs/myapp.jar ?
When I navigate to that folder on my local PC, the jarfile is there.
I'm running out of ideas on how to solve this.
You don't need to modify your stage task for that.
In your gradle.build file, make sure to give a name to your built artifact like this.
jar {
baseName = 'app'
version = '0.0.1'
}
With that been done, and the following in Procfile, it should just run fine.
web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/app-0.0.1.jar
I found that if name is not explicitly defined, heroku seems to name the artifact something like build-{buildNumber}.jar and no wonder it will never find the app.jar.
Also, if not set already, the build pack needs to be set.
heroku config:set GRADLE_TASK="build"
I eventually found a very helpful thread here: Running Spring app built with gradle on Heroku
Which helped me with my problem - this thread seems to be more detail than Heroku's official guide.
You must add the following code to your build.gradle file:
task stage(type: Copy, dependsOn: [clean, build]) {
from jar.archivePath
into project.rootDir
rename {
'app.jar'
}
}
stage.mustRunAfter(clean)
clean << {
project.file('app.jar').delete()
}
Then, point your Procfile to the app.jar:
web: java $JAVA_OPTS -jar app.jar
According to the documentation:
The Gradle buildpack will automatically detect the use of the Spring Boot and Ratpack web frameworks.
The web command should be overridden only if needed. If you're using Spring Boot, you shouldn't need to specify a Procfile at all.
Delete it, and get your app running without further configuration.
A simpler solution:
I was also encountering the same error and it was a serious waste of time for me. Unlike the ones here, I solved the problem as follows.
First of all, we need to know this.
Heroku creates a new version after each build.
For this reason, if you use a command that contains a fixed version definition in the Procfile file like build/libs/app-0.0.1-SNAPSHOT.jar, it will cause an error like this.
2022-03-02T18:19:30.797673+00:00 app[web.1]: Error: Unable to access jarfile build/libs/app-0.0.1-SNAPSHOT.jar
After the build task, Gradle creates 2 jars named app-0.0.1-SNAPSHOT.jar and app-0.0.1-SNAPSHOT-plain.jar under libs/ folder. app-0.0.1-SNAPSHOT.jar is our application including all dependencies. So I first blocked the rendering of app-0.0.1-SNAPSHOT-plain.jar as below.
jar {
enabled = false
}
Then I used the following wildcard definition in Procfile which is not affected by version changes.
web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/*.jar
The problem can also be solved in this way.
For deploying Gradle App on Heroku. Just add below lines in build.gradle file.
task stage(type: Copy, dependsOn: [clean, build]) {
from jar.archivePath
into project.rootDir
rename {
'app.jar'
}
}
stage.mustRunAfter(clean)
This also in build.gradle file for running jar file.
jar {
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'
manifest {
attributes(
'Main-Class': 'com.heroku.herokudemo.HerokuDemoApplication'
)
}
}
After this create a txt file named Procfile and add the following content.
web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/heroku-demo-0.0.1-SNAPSHOT.jar

Categories