jacekschae / learn-reitit-course-files

🎦 Learn Reitit course files for building Cheffy REST API
https://www.learnreitit.com
38 stars 16 forks source link

deploying to heroku - clojure.main not found #5

Closed jennet closed 3 years ago

jennet commented 3 years ago

Back at the beginning of the course I found that my app was not deploying to heroku properly. I decided to leave it until the end of the course in case anything was amended along the way, but no joy.

The logs show:

2021-01-19T12:09:49.000000+00:00 app[api]: Build succeeded
2021-01-19T12:09:51.303447+00:00 heroku[web.1]: Starting process with command `java -jar target/cheffy.jar clojure.main -m cheffy-api.server "resources/config.edn"`
2021-01-19T12:09:53.578867+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-01-19T12:09:53.584641+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-01-19T12:09:55.580962+00:00 app[web.1]: Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
2021-01-19T12:09:55.580971+00:00 app[web.1]: clojure.main (No such file or directory)
2021-01-19T12:09:55.580972+00:00 app[web.1]: 
2021-01-19T12:09:55.580972+00:00 app[web.1]: Full report at:
2021-01-19T12:09:55.580973+00:00 app[web.1]: /tmp/clojure-8709924226549968244.edn
2021-01-19T12:09:55.664300+00:00 heroku[web.1]: Process exited with status 1
2021-01-19T12:09:55.710413+00:00 heroku[web.1]: State changed from starting to crashed

The only thing I've done differently is that my project namespace is called cheffy-api rather than cheffy, but I still build the jar as cheffy.jar with :uberjar-name "cheffy.jar" in my project.clj

I can't see anything dubious in the log written when deploying to heroku

git push heroku master
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Delta compression using up to 8 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.12 KiB | 573.00 KiB/s, done.
Total 11 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-18 stack
remote: -----> Clojure (Leiningen 2) app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Installing rlwrap... 
remote:        Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
remote:        Hit:2 http://archive.ubuntu.com/ubuntu bionic-security InRelease
remote:        Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
remote:        Hit:4 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease
remote:        Reading package lists...
remote:        Reading package lists...
remote:        Building dependency tree...
remote:        The following NEW packages will be installed:
remote:          rlwrap
remote:        0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
remote:        Need to get 0 B/98.0 kB of archives.
remote:        After this operation, 297 kB of additional disk space will be used.
remote:        Download complete and in download only mode
remote: -----> Installing Clojure 1.10.0.411 CLI tools
remote:        Downloading and expanding tar
remote:        Installing libs into /tmp/build_33cad1c1/.heroku/clj/lib/clojure
remote:        Installing clojure and clj into /tmp/build_33cad1c1/.heroku/clj/bin
remote:        Installing man pages into /tmp/build_33cad1c1/.heroku/clj/share/man/man1
remote:        Removing download
remote:        Use clj -h for help.
remote: -----> Using cached Leiningen 2.9.1
remote:        Writing: lein script
remote: -----> Building with Leiningen
remote:        Running: lein uberjar
remote:        Downloading Leiningen to /app/.lein/self-installs/leiningen-2.9.1-standalone.jar now...
remote:          % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
remote:                                         Dload  Upload   Total   Spent    Left  Speed
remote: 100   650  100   650    0     0   5371      0 --:--:-- --:--:-- --:--:--  5371
remote: 100 13.9M  100 13.9M    0     0  43.5M      0 --:--:-- --:--:-- --:--:--  118M
remote:        Compiling cheffy-api.account.db
remote:        SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
remote:        SLF4J: Defaulting to no-operation (NOP) logger implementation
remote:        SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
remote:        Compiling cheffy-api.account.handlers
remote:        Compiling cheffy-api.account.routes
remote:        Compiling cheffy-api.auth0
remote:        Compiling cheffy-api.conversation.db
remote:        Compiling cheffy-api.conversation.routes
remote:        Compiling cheffy-api.middleware
remote:        Compiling cheffy-api.recipe.db
remote:        Compiling cheffy-api.recipe.handlers
remote:        Compiling cheffy-api.recipe.routes
remote:        Compiling cheffy-api.responses
remote:        Compiling cheffy-api.router
remote:        Compiling cheffy-api.server
remote:        Warning: environ value /tmp/build_33cad1c1/.jdk for key :java-home has been overwritten with /tmp/build_33cad1c1/.jdk/jre
remote:        Created /tmp/build_33cad1c1/target/cheffy-api-1.0.0.jar
remote:        Created /tmp/build_33cad1c1/target/cheffy.jar
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 101M
remote: -----> Launching...
remote:        Released v14
remote:        https://dry-depths-83543.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/dry-depths-83543.git
   5cd337d..ac71309  master -> master

Any ideas?

jennet commented 3 years ago

After digging through Heroku clojure support and checking against the course files, it seems the Procfile was adjusted to

web: java $JVM_OPTS -cp target/cheffy.jar clojure.main -m cheffy.server "resources/config.edn"

sometime around lesson 10

I've adjusted this for my project namespace and now the app starts OK.

I think you should probably mention this in the description of lesson 7 / Heroku deploy as I don't recall this ever being caught/explained in any of the lessons (though perhaps it was? I don't know)

jacekschae commented 3 years ago

Towards the end of the course I adopted the Heroku config 59 - Deploy

jacekschae commented 3 years ago

@jennet could we close this one? I added a note to lesson 7

jacekschae commented 3 years ago

stale