I'm building a small web app using clojure with leiningen. I have certain json files that I need to access that I also update nightly using a batch process running on my server. I am using leiningen locally, but want to deploy an uberjar to the server. in there a way for me to either update json files compressed inside the jar file, or access json files that are outside the uberjar. Right now I am trying to do the latter using ring.util.response/resource-response in a compojure route:
(GET "/json/:filename" [filename]
(resp/resource-response
(str filename ".json")
{:root "~/internal_dashboard/app/json/"}))
When my app attempts to access the files I get a 404 error. Does anyone know of a possible solution?
The JVM does not expand the
~
in paths, use a call toSystem/getenv
to get the home directory and build the path.Tomcat often runs as it's own user so make sure you either put it in the correct home dir or spell out the path completely. It may also be necessary to configure tomcat to have access to that dir.