Why is lein ring uberwar not including main manifest attribute - clojure

when I invoke java -jar my-application.war
after using lein ring uberware
I receive a response of no main manifest attribute, in my-app.war
here is my code:
the namespace below provides the :gen-class and -main function which are needed:
(ns nutrif.core
(:require [ring.middleware.params]
[ring.middleware.resource :refer [wrap-resource]]
[ring.adapter.jetty]
[clojure.java.io :as io])
(:gen-class))
(defn handler [request]
{:status 200
:header {"Content-Type" "text/html"}
:body (io/input-stream (io/resource "public/index.html"))})
(def app
(wrap-resource handler "public"))
(defn -main
[& [port]]
(let [port (Integer. (or port
(System/getenv "PORT")
8080))]
(ring.adapter.jetty/run-jetty #'app {:port port
:join? false})))
Here is the my project.clj which points to the namespace with the -main function. What am I missing ?
(defproject nutrif "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[ring "1.3.0"]
[ring/ring-jetty-adapter "1.3.0"]]
:plugins [[lein-ring "0.8.11"]]
:dev-dependencies [[ring-serve "0.1.2"]
[javax.servlet/servlet-api "2.5"]]
:ring {:handler nutrif.core/app
:resource-paths [resources public]}
:main nutrif.core
:aot [nutrif.core])

Related

BigQuery returns null for REGEXP_MATCH or _EXTRACT

I'm using the following the following query to return a subset of a string in a column:
SELECT
REGEXP_EXTRACT(content, r'/\ :dependencies\ \[(.*?)\]]\ /g') AS deps
FROM x[my-test-162023:lab.clj_files_results_030904]
but returns the following:
Row deps
1 null
2 null
3 null
4 null
5 null
6 null
I've tested the regex pattern on http://www.regexpal.com/ and https://regex101.com/r/Gjre2i/2 and it seems to be working.
Any help/hints are appreciated.
UPDATE:
The table I'm trying to query is looks like the following:
Row content
1 (defproject spaghetti "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :source-paths ["src/clj" "src/cljs"] :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2371" :scope "provided"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [ring "1.3.1"] [compojure "1.2.0"] [enlive "1.1.5"] [om "0.7.3"] [figwheel "0.1.4-SNAPSHOT"] [environ "1.0.0"] [com.cemerick/piggieback "0.1.3"] [weasel "0.4.3-SNAPSHOT"] [leiningen "2.5.0"] [http-kit "2.1.19"] [com.cognitect/transit-cljs "0.8.188"] ; [devcards "0.1.2-SNAPSHOT"] [sablono "0.2.22"] [prismatic/om-tools "0.3.3"]] :plugins [[lein-cljsbuild "1.0.3"] [lein-environ "1.0.0"]] :min-lein-version "2.5.0" :uberjar-name "spaghetti.jar" :cljsbuild {:builds {:app {:source-paths ["src/cljs/spaghetti"] :compiler {:output-to "resources/public/js/app.js" :output-dir "resources/public/js/out" :source-map "resources/public/js/out.js.map" :optimizations :none :preamble ["react/react.min.js" "public/js/adsr/index.js" "public/js/WebMIDIAPIWrapper/js/WebMIDIAPIWrapper.js" "public/js/hammerjs/hammer.min.js" "public/js/wavy-jones/wavy-jones.js"] :externs ["react/externs/react.js" "public/js/adsr/adsr.externs.js" "public/js/WebMIDIAPIWrapper/WebMIDIAPIWrapper.externs.js" "public/js/hammerjs/hammerjs.externs.js" "public/js/wavy-jonewavy-jones.externs.js"] :pretty-print true}}}} :profiles {:dev {:repl-options {:init-ns spaghetti.server :timeout 120000 :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]} :plugins [[lein-figwheel "0.1.4-SNAPSHOT"]] :figwheel {:http-server-root "public" :port 3449 :css-dirs ["resources/public/css"]} :env {:is-dev true} :cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]}}}} :uberjar {:hooks [leiningen.cljsbuild] :env {:production true} :omit-source true :aot :all :cljsbuild {:builds {:app {:source-paths ["env/prod/cljs"] :compiler {:optimizations :advanced :pretty-print false }}}}}})
2 (defproject pomodoro "0.0.4" :license {:name "MIT" :url "http://opensource.org/licenses/MIT" :distribution :repo} :description "A simple pomodoro timer" :url "https://github.com/landau/cljs-pomodoro" :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2322"] [org.clojure/core.async "0.1.338.0-5c5012-alpha"] [com.andrewmcveigh/cljs-time "0.1.6"] [reagent "0.4.2"]] :plugins [[lein-ring "0.8.11"] [lein-cljsbuild "1.0.3"] [lein-environ "0.5.0"]] :ring {:handler server.core/app} :profiles {:uberjar {:aot :all} :dev {:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.3.0"] [compojure "1.1.9"]] :env {:dev true}} :release {:ring {:open-browser? false :stacktraces? false :auto-reload? false}}} :source-paths ["src"] :main server.core :cljsbuild { :builds [{:id "dev" :source-paths ["src-cljs"] :compiler {:output-to "public/js/pomodoro.js" :output-dir "public/js/dev" :optimizations :none :pretty-print tru :source-map true}} {:id "prod" :source-paths ["src-cljs"] :compiler {:output-to "public/js/main.js" :optimizations :advanced :pretty-print false :externs ["public/js/react-min-0.11.2.js"] }}]})
3 (defproject datascript-mori "0.15.2" :description "Wrapper for datascript interplay mori" :url "https://github.com/typeetfunc/datascript-mori" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :min-lein-version "2.5.3" :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "1.7.170"] [datascript "0.15.0"]] :plugins [[lein-cljsbuild "1.1.2" :exclusions [[org.clojure/clojure]]] [lein-git-deps "0.0.2-SNAPSHOT"]] :git-dependencies [["https://github.com/swannodette/mori.git"]] :source-paths ["src" ".lein-git-deps/mori/src"] :clean-targets ^{:protect false} ["target"] :cljsbuild {:builds [{:id "min" :source-paths ["src" ".lein-git-deps/mori/src"] :compiler { :output-to "release-js/datascript-mori.bare.js" :main datascript-mori.core :optimizations :advanced :pretty-print false } :notify-command ["release-js/wrap_bare.sh"]}]} )
4 (defproject pandect "0.6.1-SNAPSHOT" :description "Message Digest and Checksum Library for Clojure" :url "https://github.com/xsc/pandect" :license {:name "MIT License" :url "https://opensource.org/licenses/MIT" :year 2014 :key "mit"} :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"] [org.bouncycastle/bcprov-jdk15on "1.54" :scope "provided"]] :exclusions [org.clojure/clojure] :source-paths ["src/clojure" "target/generated"] :java-source-paths ["src/java"] :profiles {:dev {:plugins [[lein-codox "0.9.4"]] :codox {:project {:name "pandect"} :metadata {:doc/format :markdown} :output-path "doc" :namespaces [pandect.core pandect.buffer #"^pandect\.algo\.[a-z\-]+"]}} :benchmark {:dependencies [[criterium "0.4.3"] [clj-message-digest "1.0.0"] [digest "1.4.4"]] :source-paths ["shootout"] :jvm-opts ^:replace ["-Xmx1g" "-server"]} :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]} :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]} :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}} :prep-tasks ["codegen"] :aliases {"benchmark" ["with-profile" "dev,benchmark" "run" "-m"] "codegen" ["run" "-m" "pandect.codegen"] "all" ["with-profile" "+dev:+1.5:+1.6:+1.7"]} :pedantic? :abort)
5 (defproject stch-library/sql "0.1.1" :description "A DSL in Clojure for SQL query, DML, and DDL." :url "https://github.com/stch-library/sql" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [stch-library/schema "0.3.3"]] :profiles {:dev {:dependencies [[speclj "3.0.2"]]}} :plugins [[speclj "3.0.2"] [codox "0.6.7"]] :codox {:src-dir-uri "https://github.com/stch-library/sql/blob/master/" :src-linenum-anchor-prefix "L"} :test-paths ["spec"])
6 (defproject laboratory "0.1.0-SNAPSHOT" :description "do science in production" :url "https://github.com/yeller/laboratory" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"]] :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.4"]]} :benches {:dependencies [[criterium "0.4.1"]] :source-paths ["src" "benches"]}} :global-vars {*warn-on-reflection* true *unchecked-math* :warn-on-boxed ;*compiler-options* {:disable-locals-clearing true} *assert* true})
/g means that you want to extract all matches, not just one which is what REGEXP_EXTRACT does.
You should use REGEXP_EXTRACT_ALL instead, along with UNNEST
So try below
#standardSQL
SELECT deps
FROM `my-test-23.lab.clj_project_files`,
UNNEST(REGEXP_EXTRACT_ALL(content, r' :dependencies \[(.*?)\]] ')) AS deps
got "Query returned zero records" ....
Try below with dummy data based on your example (just stripped first two rows)
#standardSQL
WITH yourTable AS (
SELECT 1 AS id, '(defproject :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2371" :scope "provided"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [ring "1.3.1"] [compojure "1.2.0"] [enlive "1.1.5"] [om "0.7.3"] [figwheel "0.1.4-SNAPSHOT"] [environ "1.0.0"] [com.cemerick/piggieback "0.1.3"] [weasel "0.4.3-SNAPSHOT"] [leiningen "2.5.0"] [http-kit "2.1.19"] [com.cognitect/transit-cljs "0.8.188"] ; [devcards "0.1.2-SNAPSHOT"] [sablono "0.2.22"] [prismatic/om-tools "0.3.3"]] :plugins [[lein-cljsbuild "1.0.3"] [lein-environ "1.0.0"]] ' AS content UNION ALL
SELECT 2, '(defproject :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2322"] [org.clojure/core.async "0.1.338.0-5c5012-alpha"] [com.andrewmcveigh/cljs-time "0.1.6"] [reagent "0.4.2"]] :plugins [[lein-ring "0.8.11"] [lein-cljsbuild "1.0.3"] [lein-environ "0.5.0"]] :ring {:handler server.core/app} :profiles {:uberjar {:aot :all} :dev {:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.3.0"] [compojure "1.1.9"]] :env {:dev true}} '
)
SELECT id, deps
FROM yourTable, UNNEST(SPLIT(REPLACE(
REGEXP_EXTRACT(content, r' :dependencies \[(\[.*?])*] ')
,'] [', '],['))) AS deps
ORDER BY id
Result is as below
Row id deps
1 1 [org.clojure/clojurescript "0.0-2371" :scope "provided"]
2 1 [prismatic/om-tools "0.3.3"]
3 1 [sablono "0.2.22"]
4 1 [com.cognitect/transit-cljs "0.8.188"] ; [devcards "0.1.2-SNAPSHOT"]
5 1 [http-kit "2.1.19"]
6 1 [leiningen "2.5.0"]
7 1 [weasel "0.4.3-SNAPSHOT"]
8 1 [com.cemerick/piggieback "0.1.3"]
9 1 [environ "1.0.0"]
10 1 [figwheel "0.1.4-SNAPSHOT"]
11 1 [om "0.7.3"]
12 1 [enlive "1.1.5"]
13 1 [compojure "1.2.0"]
14 1 [ring "1.3.1"]
15 1 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
16 1 [org.clojure/clojure "1.6.0"]
17 2 [org.clojure/clojure "1.6.0"]
18 2 [org.clojure/clojurescript "0.0-2322"]
19 2 [org.clojure/core.async "0.1.338.0-5c5012-alpha"]
20 2 [com.andrewmcveigh/cljs-time "0.1.6"]
21 2 [reagent "0.4.2"]
... but if I remove that and run it on my own dataset/table I don't get any results ...
Looks like your real data is "slightly" different from how it shown in your question
Try below - it should work now :o)
#standardSQL
SELECT id, deps
FROM `my-test-23.lab.clj_project_files`,
UNNEST(SPLIT(REGEXP_REPLACE(
REGEXP_EXTRACT(content, r'(?s) :dependencies \[(\[.*?])]')
, r']\n *\[', '],['))) AS deps
ORDER BY id

Reagent ClojureScript

I am working on a Reagent project, and seem to not be able to use a macros.clj file. No matter where I put it, it keeps giving me the same message: "could not locate macros/core__init.class or macros/core.clj on classpath. Where should I be putting my macros.clj file, or what am I missing?
The structure is as follows:
test-proj/
env/
dev/
clj/
test-proj/
middleware.clj
repl.clj
cljs/
test-proj/
dev.cljs
prod/
clj/
test-proj/
middleware.clj
cljs/
test-proj/
prod.cljs
resources/
public/
css/
site.css
src/
clj/
test-proj/
handler.clj
server.clj
cljc/
test-proj/
util.cljc
cljs/
test-proj/
bmi.cljs
core.cljs
home.cljs
macros.clj
simple-examples.cljs
timer.cljs
todo.cljs
target/
classes/
META-INF/
maven/
test-proj/
test/proj/
pom.properties
cljsbuild/
public/
js/
out/
...
app.js
stale/
leiningen.core.classpath.extract-native-dependencies
leiningen.figwheel.clean-on-dependency-change
figwheel_server.log
LICENSE
Procfile
project.clj
README.md
system.properties
The namespace in my core.cljs file looks as such:
(ns test-proj.core
(:require [reagent.core :as reagent :refer [atom]]
[reagent.session :as session]
[secretary.core :as secretary :include-macros true]
[accountant.core :as accountant]
[home.core :as h]
[simple-examples.core :as se]
[bmi.core :as b]
[timer.core :as t]
[todo.core :as td])
(:require-macros [macros.core :as m]))
The namespace for my macros.core looks as follows:
(ns macros.core)
My project.clj file looks as follows:
(defproject test-proj "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[ring-server "0.4.0"]
[reagent "0.6.0"]
[reagent-utils "0.2.0"]
[ring "1.5.0"]
[ring/ring-defaults "0.2.1"]
[compojure "1.5.1"]
[hiccup "1.0.5"]
[yogthos/config "0.8"]
[org.clojure/clojurescript "1.9.473"
:scope "provided"]
[secretary "1.2.3"]
[venantius/accountant "0.1.7"
:exclusions [org.clojure/tools.reader]]]
:plugins [[lein-environ "1.0.2"]
[lein-cljsbuild "1.1.1"]
[lein-ring "0.11.0"]
[lein-asset-minifier "0.2.7"
:exclusions [org.clojure/clojure]]]
:ring {:handler test-proj.handler/app
:uberwar-name "test-proj.war"}
:min-lein-version "2.5.0"
:uberjar-name "test-proj.jar"
:main test-proj.server
:clean-targets ^{:protect false}
[:target-path
[:cljsbuild :builds :app :compiler :output-dir]
[:cljsbuild :builds :app :compiler :output-to]]
:source-paths ["src/clj" "src/cljc"]
:resource-paths ["resources" "target/cljsbuild"]
:minify-assets
{:assets
{"resources/public/css/site.min.css" "resources/public/css/site.css"}}
:cljsbuild
{:builds {:min
{:source-paths ["src/cljs" "src/cljc" "env/prod/cljs"]
:compiler
{:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/uberjar"
:optimizations :advanced
:pretty-print false}}
:app
{:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
:compiler
{:main "test-proj.dev"
:asset-path "/js/out"
:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/out"
:source-map true
:optimizations :none
:pretty-print true}}
}
}
:figwheel
{:http-server-root "public"
:server-port 3449
:nrepl-port 7002
:nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"
]
:css-dirs ["resources/public/css"]
:ring-handler test-proj.handler/app}
:profiles {:dev {:repl-options {:init-ns test-proj.repl
:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:dependencies [[ring/ring-mock "0.3.0"]
[ring/ring-devel "1.5.0"]
[prone "1.1.4"]
[figwheel-sidecar "0.5.8"]
[org.clojure/tools.nrepl "0.2.12"]
[com.cemerick/piggieback "0.2.2-SNAPSHOT"]
[pjstadig/humane-test-output "0.8.1"]
]
:source-paths ["env/dev/clj"]
:plugins [[lein-figwheel "0.5.8"]
]
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]
:env {:dev true}}
:uberjar {:hooks [minify-assets.plugin/hooks]
:source-paths ["env/prod/clj"]
:prep-tasks ["compile" ["cljsbuild" "once" "min"]]
:env {:production true}
:aot :all
:omit-source true}})
The error:
---- Could not Analyze src/cljs/test-proj/core.cljs ----
Could not locate macros/core__init.class or macros/core.clj on classpath.
---- Analysis Error : Please see src/cljs/test-proj/core.cljs ----
To use macros from Clojurescript:
(ns my.namespace
(:require-macros [my.macros :as my]))
Here's the documentation: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#macros

Failing to create WAR file from Immutant

When I attempt to create a war file via the command
lein with-profile prod immutant war
I get an error stating:
Error encountered performing task 'immutant' with profile(s): 'prod'
Uberjar aborting because jar failed: No implementation of method:
:as-file of protocol: #'clojure.java.io/Coercions found for class:
java.lang.Character
My project file is as below
(defproject company/project-name "0.0.2-SNAPSHOT"
:description "project description"
:url "http://www.comapny-url.com"
:license {:name "company name license"
:url "http://www.company-url.com"}
:min-lein-version "2.4.3"
:java-opts ["-Xmx5g" "-server" "-XX:-OmitStackTraceInFastThrow"]
:exclusions [org.clojure/clojure]
:dependencies [[company/lib-name1 "1.2.9" :exclusions [com.taoensso/encore]]
[company/lib-name2 "1.1.1"]
[org.clojure/clojure "1.6.0"]
[org.clojure/data.zip "0.1.1"]
[org.clojure/tools.nrepl "0.2.10"]
[com.palletops/leaven "0.3.1"]
[com.github.kyleburton/clj-xpath "1.4.5"]
[metrics-clojure "2.5.1"]]
:java-source-paths ["java/src"]
:javac-options ["-target" "1.7"
"-source" "1.7" "-Xlint:-options"
"-cp" "resources/jars/jms-lib.jar:resources/jars/clojure-1.6.0.jar:resources/jars/log4j-1.2.17.jar"
"-d" "resources/classes"]
:profiles {:dev {:source-paths ["dev"]
:dependencies [[org.clojure/tools.namespace "0.2.11"]]
:plugins [[lein-package "2.1.1"]
[lein-marginalia "0.7.1"]]}
:prod {:source-paths "prod"
:main prod}}
:prep-tasks ["javac" "compile"]
:resource-paths ["resources/classes"]
:plugins [[lein-package "2.1.1"]
[lein-immutant "2.0.1"]]
:immutant {:war {:resource-paths ["war-resources"]}
:nrepl {:port 8183
:host "0.0.0.0"
:interface "0.0.0.0"
:start? true}}
:hooks [leiningen.package.hooks.deploy leiningen.package.hooks.install]
:package {:skipjar true
:autobuild true
:reuse false
:artifacts [{:build "with-profile prod immutant war --name=%p%v%t" :extension "war"}]}
:uberjar-exclusions [#"(?i)^META-INF/[^/]*\.SF$"] ;; Eliminate the signing code from the uberjar
:repositories ^:replace [["nexus" {:url "comapny.respository.net"}]])
The prod profile is laid out like so
(ns prod
(:require
[company.lib-name3
[debug :as debug]
[system :refer (go)]])
(:gen-class))
(defn -main
"Initialize and start the app as a war"
[]
(go))
I can build up an uberjar if I use my dev profile which is laid out as so:
(ns user
"Tools for interactive development with the REPL. This file should
not be included in a production build of the application."
(:require [clojure.java.io :as io]
[clojure.java.javadoc :refer (javadoc)]
[clojure.pprint :refer (pprint)]
[clojure.reflect :refer (reflect)]
[clojure.repl :refer (apropos dir doc find-doc pst source)]
[clojure.set :as set]
[clojure.string :as str]
[clojure.test :as test]
[clojure.tools.namespace.repl :refer (refresh refresh-all)]
[company.lib-name3
[debug :as debug]
[system :refer (go)]]))
(defn -main
[]
(go))
The source paths in the prod profile of my project.clj file need to be in a vector, not just be a string.
:profiles {:dev {:source-paths ["dev"]
:dependencies [[org.clojure/tools.namespace "0.2.11"]]
:plugins [[lein-package "2.1.1"]
[lein-marginalia "0.7.1"]]}
:prod {:source-paths ["prod"]
:main prod}}
instead of
:profiles {:dev {:source-paths ["dev"]
:dependencies [[org.clojure/tools.namespace "0.2.11"]]
:plugins [[lein-package "2.1.1"]
[lein-marginalia "0.7.1"]]}
:prod {:source-paths "prod"
:main prod}}

leincljs build error : java.lang.IllegalStateException

I have just run lein cljsbuild once in my lein project directory, and I got the error java.lang.IllegalStateException : Can't dynamically bind non-dynamic var: clojure.tools.reader/resolve-symbol
Stacktrace:
https://gist.githubusercontent.com/fyquah95/0a02b06c0a9aa2225f9c/raw/0cc05629a18c3711e27b1fc9dd59db0532d964b8/gistfile1.txt
My project.clj file:
(defproject barclays-cycle-hire-stats "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:main barclays-cycle-hire-stats.core
:plugins [[lein-cljsbuild "1.0.6"]
[lein-ring "0.8.7"]]
:source-paths ["src/clj"]
:cljsbuild {
:builds [{:source-paths ["src/cljs"]
:compiler {:output-to "resources/public/js/main.js"
:optimizations :whitespace
:pretty-print true}}]}
:dependencies [[http-kit "2.1.18"]
[reagent "0.5.1-rc"]
[cljs-ajax "0.3.14"]
[compojure "1.1.6"]
[hiccup "1.0.4"]
[org.clojure/math.numeric-tower "0.0.4"]
; [org.clojure/clojure.core.async "0.1.346.0-17112a-alpha"]
[spyscope "0.1.5"]
[org.clojure/math.combinatorics "0.1.1"]
[org.clojure/data.json "0.2.6"]
[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.48" :exclusion [org.clojure/data.json]]
[org.clojure/data.csv "0.1.3"]]
:eval-in-leiningen true
:ring {:handler barclays-cycle-hire-stats.routes/app})
Try without :eval-in-leiningen true.
:eval-in-leiningen is intended for plugins, and it's a source of weird errors when used in a project.
You can find information about :eval-in-leiningen and :eval-in-project in the Project isolation section of leiningen.core doc, and Plugins doc of leiningen
Adding :exclusions [org.apache.ant/ant] to clojurescript dependency fixed the same error message for me. So it looks like this:
[org.clojure/clojurescript "1.7.48" :exclusions [org.apache.ant/ant]]

Why does ring's resource-response respond with application/octet-stream content type?

I am trying to figure out why Ring's resource-response is choosing to respond with an application/octet-stream content type. I recently updated some sample code, that I've been learning from, so that it uses the newer ring-defaults. Prior to using ring-defaults, this code responded with the html content type. Why is this now choosing octet-stream?
(ns replays.handler
(:require [compojure.core :refer [GET defroutes]]
[compojure.route :as route]
[ring.util.response :refer [response resource-response]]
[ring.middleware.json :as middleware]
[ring.middleware.defaults :refer [wrap-defaults api-defaults]]))
(defroutes app-routes
(GET "/" [] (resource-response "index.html" {:root "public"}))
(GET "/widgets" [] (response [{:name "Widget 1"} {:name "Widget 2"}]))
(route/resources "/public")
(route/not-found "not found"))
(def app
(-> app-routes
(middleware/wrap-json-body)
(middleware/wrap-json-response)
(wrap-defaults api-defaults)))
And, for version numbers, here's the project file ...
(defproject replays "0.1.0-SNAPSHOT"
:url "http://example.com/FIXME"
:description "FIXME: write description"
:plugins [[lein-pdo "0.1.1"]
[lein-ring "0.9.3"]
[lein-cljsbuild "1.0.5"]]
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[org.clojure/clojurescript "0.0-3126"]
[org.omcljs/om "0.8.8"]
[ring/ring-core "1.3.2"]
[ring/ring-json "0.3.1"]
[ring/ring-defaults "0.1.4"]
[compojure "1.3.2"]
[cljs-http "0.1.29"]]
:source-paths ["src/clj"]
:ring {:handler replays.handler/app}
:cljsbuild {:builds [{:id "dev"
:source-paths ["src/cljs"]
:compiler {:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/out"
:optimizations :none
:source-map true}}]}
:aliases {"up" ["pdo" "cljsbuild" "auto" "dev," "ring" "server-headless"]}
:profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]]}})
This is happening because api-defaults (actually it's ring.middleware.content-type) tries to guess your content-type based on the data you passed to it. It uses file extensions to do that and since you are using resource-response, there is no extension. So by default ring.middleware.content-type uses application/octet-stream.
The solution is to provide your content-type to the response like below:
(ns app.routes
(:require [compojure.core :refer [defroutes GET]]
[ring.util.response :as resp]))
(defroutes appRoutes
;; ...
;; your routes
;; ...
(GET "/"
resp/content-type (resp/resource-response "index.html" {:root "public"}) "text/html"))