I am new to Heroku. The backend logic of my flask web app is actually running a Java subprocess (subprocess.call( ...) ) to get some helper data. (I know it's a bad thing to do)
On deployment, Heroku works as expected and installs Python runtime and frameworks from requirements.txt but not JDK.
Any way I can configure Java in the same and make this work ??
Run the following command:
$ heroku buildpacks:add heroku/jvm
Then redeploy with a git push heroku master. This will install the JDK into your slug.
Related
I recently run into an "H14 Error" While Trying To Deploy Gradle Spring Project into the HeroKu platform.
Error:
code=H14 desc="No web processes running"
In My Project Folder, I have a "Procfile"
web: java -jar build/server/webapp-runner-*.jar build/libs/*.war
web: java -jar target/ClockGUI-0.0.1-SNAPSHOT.jar
heroku ps:scale web=1
I have researched many solutions but not worked out.
Please help me. Thank you so much
There are at least two issues with your Procfile:
You can't declare two web processes.
What command runs your web server? That's the only one that should be declared this way.
(I'm not sure what ClockGUI-0.0.1-SNAPSHOT.jar is supposed to be, but assuming "GUI" means something like SWT, Swing, or JavaFX, it won't work on Heroku. Where would the interface appear?)
You've included a Heroku CLI command.
heroku ps:scale web=1 is a command that you might run locally to scale your application's web dynos. It's not something that should be baked into the application source code.
Consider an e-commerce application. At certain times of the year, you might see a spike in traffic. You could use this command to scale up additional web dynos to handle the load. That doesn't (and shouldn't) require redeploying the application.
Remove that line. It doesn't do anything in the Procfile anyway.
Commit the updated Procfile and redeploy. Then, if you don't have any web dynos running, run heroku ps:scale web=1 in a terminal, ideally from your project directory so Heroku can infer which app you want to scale.
I'm looking for a way to run Heroku CLI commands within a java application hosted on Heroku.
I'd like to be able to run commands like heroku pg:backup heroku pg:restore etc
Is there a way to do that ?
EDIT : I added the Heroku CLI to my app, now I'm looking for a way to invoke heroku commands from my java code.
Maybe you could use something like this :
ProcessBuilder pb = new ProcessBuilder("/path/to/herokuCLI", "myCommand");
Problem is I don't know how to find the right path.
If you look at the file structure of your app on Heroku you can only find your .war + some "configuration files" which is quite normal as you only push a war to Heroku : Procfile system.properties target
Besides I don't think that's the right way to do that.
I'd like to avoid doing backup/restore operations in pure java code.
Maybe you can't rely on Heroku cmd to do the job for you after all.
You'll need to add the Heroku CLI buildpack to your application. You can do so with: heroku buildpacks:add heroku-community/cli
Push a new build after you've done so and you'll now be able to run CLI commands from inside your application dynos. You can see some additional information about this in the documentation.
I've a java web application and I want to install node server in the background so I can execute js files from java in Heroku.
I want to execute node myFile.js
Add the Node.js buildpack to you app by running:
$ heroku buildpacks:add heroku/nodejs
And make sure you have a package.json file in your app.
My Rails app relies on legacy Java code for a piece of its logic. It runs the code via shell commands: javac whatever and then java whatever. However, after deploying to Heroku, the request fails because it can't locate javac or java.
What's the best way to install Java in a Rails app? I tried using a multi-buildpack solution, with this .buildpacks:
https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/heroku/heroku-buildpack-java.git
But I get this error:
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-java.git
! Push rejected, failed to compile Multipack app
I tried forking the Ruby buildpack and installing Java directly from there, but I don't really know what I'm doing. Any ideas?
Try using heroku-buildpack-jvm-common instead of the Java buildpack. So your .buildpacks file will look like this:
https://github.com/heroku/heroku-buildpack-jvm-common.git
https://github.com/heroku/heroku-buildpack-ruby.git
It's probably a good idea to put the JVM one before the Ruby one in case javac or java are needed at compile/build time.
The JVM buildpack is essentially the same as the Java buildpack, but doesn't install Maven and thus does not require a pom.xml file. The missing pom.xml is why you got that error I think.
EDIT
In the modern era, you can also run:
$ heroku buildpacks:add heroku/jvm
$ heroku buildpacks:add heroku/ruby
Trying to install java agent on tomcat.
successfully run
java -jar newrelic.jar install
then run apache, but not see any newrilc initialization messages in catalina out, and not found any logs in newrelic directory.
General guidance on this install process:
The script should print out a good amount of detail on what it's done, including where it detected your Tomcat instance. If nothing's showing up in your CLI, then it's likely you haven't started the install script.
You can use -h to see usage help, and -s /path/to/applicationserver if you want to make sure the script find your web app. Note that a clear error message should show up if the install script can't find your web app.
The install script is fairly simple, and you can perform a manual install with the steps in the New Relic documentation (broken out by framework).