I have my main class:
public class Main {
public static void main(String[] args){
Spark.port(getHerokuAssignedPort());
get("/hello", (req, res) -> "Hello Heroku World");
}
private static int getHerokuAssignedPort() {
ProcessBuilder processBuilder = new ProcessBuilder();
if (processBuilder.environment().get("PORT") != null) {
return Integer.parseInt(processBuilder.environment().get("PORT"));
}
return 4567; //return default port if heroku-port isn't set (i.e. on localhost)
}
}
My procfile:
web: java -jar build/libs/CrowdSubhaHeroku-1.0-SNAPSHOT-all.jar
Note: I'm using shadowJar since a normal jar creation doesn't include dependencies I need such as Spark and Firebase.
Now, if I do:
heroku local web
And go to localhost:5000
, I get a 404 error. However, the application doesn't actually crash. It stays running.
That is unlike when I do:
heroku open
After a git add .
, git commit -m "x"
, and a git push heroku master
Which crashes with an "Application Error" and gives me this ONLY:
2017-02-23T15:18:18.848727+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=crowdsubha.herokuapp.com request_id=ce636951-862e-4b2f-a698-924db3039a07 fwd="94.187.7.67" dyno= connect= service= status=503 bytes=
2017-02-23T15:18:20.022743+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myapp.herokuapp.com request_id=d1e9ec86-ffe4-4a09-9934-81e25378c32c fwd="94.187.7.67" dyno= connect= service= status=503 bytes=
Those are the only errors I got. The previous errors are the logs from yesterday.
I'm not exactly sure what's the problem. I suspect it has something to do with the shadowJar
. But I'm not sure.
heroku logs -t
and leave it running. Then in another terminal session runheroku ps:restart
? If you see an error message, please add it here. – Needlefulheroku run ls build/libs/
. However, the regular jar file is being deployed. But the regular jar file doesn't contain the gradle dependencies for some reason, and I can't use Spark if I'm using the regular jar – Ghyll./gradlew clean stage
? – Needleful