Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Leiningen's classpath: /home/vagrant/.lein/self-installs/leiningen-2.0.0-preview10-standalone.jar
Exception in thread "main" java.lang.IllegalAccessError: add-encoder does not exist, compiling:(json.clj:1)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3387)
at clojure.lang.Compiler.compile1(Compiler.java:7035)
at clojure.lang.Compiler.compile1(Compiler.java:7025)
at clojure.lang.Compiler.compile(Compiler.java:7097)
at clojure.lang.RT.compile(RT.java:387)
at clojure.lang.RT.load(RT.java:427)
at clojure.lang.RT.load(RT.java:400)
at clojure.core$load$fn__4890.invoke(core.clj:5415)
at clojure.core$load.doInvoke(core.clj:5414)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5227)
at clojure.core$load_lib.doInvoke(core.clj:5264)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$load_libs.doInvoke(core.clj:5298)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$require.doInvoke(core.clj:5381)
at clojure.lang.RestFn.invoke(RestFn.java:3894)
at api.core$loading__4784__auto__.invoke(core.clj:1)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3382)
at clojure.lang.Compiler.compile1(Compiler.java:7035)
at clojure.lang.Compiler.compile1(Compiler.java:7025)
at clojure.lang.Compiler.compile(Compiler.java:7097)
at clojure.lang.RT.compile(RT.java:387)
at clojure.lang.RT.load(RT.java:427)
at clojure.lang.RT.load(RT.java:400)
at clojure.core$load$fn__4890.invoke(core.clj:5415)
at clojure.core$load.doInvoke(core.clj:5414)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5227)
at clojure.core$compile$fn__4895.invoke(core.clj:5426)
at clojure.core$compile.invoke(core.clj:5425)
at user$eval31.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6511)
at clojure.lang.Compiler.eval(Compiler.java:6501)
at clojure.lang.Compiler.eval(Compiler.java:6477)
at clojure.core$eval.invoke(core.clj:2797)
at clojure.main$eval_opt.invoke(main.clj:297)
at clojure.main$initialize.invoke(main.clj:316)
at clojure.main$null_opt.invoke(main.clj:349)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalAccessError: add-encoder does not exist
at clojure.core$refer.doInvoke(core.clj:3778)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$load_lib.doInvoke(core.clj:5279)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$load_libs.doInvoke(core.clj:5298)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$require.doInvoke(core.clj:5381)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at ring.middleware.json$loading__4784__auto__.invoke(json.clj:1)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3382)
... 48 more
[cheshire "5.0.1"]
[com.fasterxml.jackson.core/jackson-core "2.1.1"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.1.1"]
[clj-base64 "0.0.2"]
[clj-http "0.6.1"]
[crouton "0.1.1"]
[org.jsoup/jsoup "1.7.1"]
[org.apache.httpcomponents/httpcore "4.2.3"]
[org.apache.httpcomponents/httpmime "4.2.2"]
[clj-json "0.5.3"]
[org.codehaus.jackson/jackson-core-asl "1.9.9"]
[clj-stacktrace "0.2.4"]
[com.ashafa/clutch "0.4.0-RC1"]
[com.cemerick/url "0.0.6"]
[pathetic "0.4.0"]
[com.cemerick/friend "0.1.3"]
[com.google.inject/guice "2.0"]
[aopalliance "1.0"]
[net.sourceforge.nekohtml/nekohtml "1.9.10"]
[xerces/xercesImpl "2.8.1"]
[xml-apis "1.3.03"]
[org.apache.httpcomponents/httpclient "4.2.1"]
[org.clojure/core.cache "0.6.2"]
[org.clojure/core.incubator "0.1.1"]
[org.mindrot/jbcrypt "0.3m"]
[org.openid4java/openid4java-nodeps "0.9.6" :exclusions [[com.google.code.guice/guice]]]
[commons-logging "1.1.1"]
[net.jcip/jcip-annotations "1.0"]
[com.cemerick/pomegranate "0.0.13"]
[org.apache.maven.wagon/wagon-http "2.2"]
[org.apache.maven.wagon/wagon-http-shared4 "2.2"]
[org.apache.maven.wagon/wagon-provider-api "2.2"]
[org.apache.maven/maven-aether-provider "3.0.4"]
[org.apache.maven/maven-model-builder "3.0.4"]
[org.codehaus.plexus/plexus-interpolation "1.14"]
[org.apache.maven/maven-model "3.0.4"]
[org.apache.maven/maven-repository-metadata "3.0.4"]
[org.codehaus.plexus/plexus-component-annotations "1.5.5" :exclusions [[junit]]]
[org.sonatype.aether/aether-api "1.13.1"]
[org.sonatype.aether/aether-connector-file "1.13.1"]
[org.sonatype.aether/aether-connector-wagon "1.13.1"]
[org.codehaus.plexus/plexus-classworlds "2.4"]
[org.codehaus.plexus/plexus-utils "2.0.7"]
[org.sonatype.sisu/sisu-inject-plexus "2.2.3"]
[org.sonatype.sisu/sisu-inject-bean "2.2.3"]
[org.sonatype.sisu/sisu-guice "3.0.3" :classifier "no_aop" :exclusions [[javax.inject] [aopalliance]]]
[org.sonatype.aether/aether-impl "1.13.1"]
[org.sonatype.aether/aether-spi "1.13.1"]
[org.sonatype.aether/aether-util "1.13.1"]
[com.datomic/datomic-free "0.8.3655"]
[com.amazonaws/aws-java-sdk "1.3.0" :exclusions [[javax.mail/mail] [org.codehaus.jackson/jackson-core-asl] [org.apache.httpcomponents/httpclient] [commons-logging]]]
[com.google.guava/guava "12.0.1"]
[com.google.code.findbugs/jsr305 "1.3.9"]
[com.h2database/h2 "1.3.165"]
[net.java.dev.jets3t/jets3t "0.8.1" :exclusions [[commons-logging] [commons-codec]]]
[com.jamesmurty.utils/java-xmlbuilder "0.4"]
[commons-httpclient "3.1" :exclusions [[commons-codec] [commons-logging]]]
[org.apache.lucene/lucene-core "3.3.0"]
[org.apache.tomcat/tomcat-jdbc "7.0.27" :exclusions [[commons-logging]]]
[org.apache.tomcat/tomcat-juli "7.0.27"]
[org.clojure/tools.cli "0.2.2"]
[org.codehaus.janino/commons-compiler-jdk "2.6.1"]
[org.codehaus.janino/commons-compiler "2.6.1"]
[org.fressian/fressian "0.6.3"]
[org.hornetq/hornetq-core "2.2.2.Final"]
[org.jboss.netty/netty "3.2.4.Final"]
[org.slf4j/jcl-over-slf4j "1.6.4"]
[org.slf4j/jul-to-slf4j "1.6.4"]
[org.slf4j/slf4j-api "1.6.4"]
[org.slf4j/log4j-over-slf4j "1.6.4" :scope "runtime"]
[org.slf4j/slf4j-nop "1.6.4"]
[postgresql "9.1-901.jdbc4"]
[spy/spymemcached "2.8.1"]
[com.novemberain/langohr "1.0.0-beta10"]
[clojurewerkz/support "0.7.0"]
[com.rabbitmq/amqp-client "2.8.6"]
[compojure "1.1.3"]
[clout "1.0.1"]
[org.clojure/tools.macro "0.1.0"]
[conformity "0.1.0"]
[datomic-session "0.1.0"]
[fn.trace "1.3.0.2"]
[fs "1.3.2"]
[org.apache.commons/commons-compress "1.3"]
[lib-noir "0.2.0"]
[ring "1.1.1"]
[ring/ring-devel "1.1.1"]
[hiccup "1.0.0"]
[ns-tracker "0.1.1"]
[org.clojure/tools.namespace "0.1.0"]
[org.clojure/java.classpath "0.1.0"]
[org.clojure/clojure "1.4.0"]
[org.clojure/data.json "0.2.0"]
[org.clojure/data.xml "0.0.6"]
[org.clojure/data.zip "0.1.0"]
[peridot "0.0.8"]
[ring-mock "0.1.3"]
[potemkin "0.1.6"]
[ring-basic-authentication "1.0.1"]
[org.clojure/data.codec "0.1.0"]
[ring/ring-core "1.1.6"]
[clj-time "0.3.7"]
[commons-codec "1.6"]
[commons-fileupload "1.2.1"]
[commons-io "2.1"]
[javax.servlet/servlet-api "2.5"]
[ring/ring-jetty-adapter "1.1.5"]
[org.eclipse.jetty/jetty-server "7.6.1.v20120215"]
[org.eclipse.jetty.orbit/javax.servlet "2.5.0.v201103041518"]
[org.eclipse.jetty/jetty-continuation "7.6.1.v20120215"]
[org.eclipse.jetty/jetty-http "7.6.1.v20120215"]
[org.eclipse.jetty/jetty-io "7.6.1.v20120215"]
[org.eclipse.jetty/jetty-util "7.6.1.v20120215"]
[ring/ring-servlet "1.1.5"]
[robert/hooke "1.3.0"]
[slingshot "0.10.3"]
[spyscope "0.1.2"]
[zolodeck/demonic "0.1.0-20130206.010740-127"]
[org.clojure/tools.logging "0.2.4"]
[zolodeck/zolo-utils "0.1.0-20130206.010459-96"]
[clj-oauth2 "0.2.0" :exclusions [[org.clojure/tools.logging] [commons-logging] [log4j] [org.slf4j/slf4j-nop] [org.slf4j/slf4j-api] [org.slf4j/slf4j-log4j12] [org.clojure/clojure]]]
[uri "1.1.0"]
[org.clojure/clojure-contrib "1.2.0"]
[com.joestelmach/natty "0.6-20120626.204640-1" :exclusions [[org.clojure/tools.logging] [commons-logging] [log4j] [org.slf4j/slf4j-nop] [org.slf4j/slf4j-api] [org.slf4j/slf4j-log4j12] [org.clojure/clojure]]]
[antlr "2.7.7"]
[org.antlr/antlr-runtime "3.2"]
[org.antlr/stringtemplate "3.2"]
[org.mnode.ical4j/ical4j "1.0.2"]
[backport-util-concurrent "3.1"]
[commons-lang "2.6"]
[joda-time "1.6" :exclusions [[org.clojure/tools.logging] [commons-logging] [log4j] [org.slf4j/slf4j-nop] [org.slf4j/slf4j-api] [org.slf4j/slf4j-log4j12] [org.clojure/clojure]]]
(defproject clojure-api "0.1.0-SNAPSHOT"
:description ""
:url ""
:license {:name "none"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]
[spyscope "0.1.2"]
[org.clojure/data.zip "0.1.0"]
[org.clojure/data.xml "0.0.6"]
[potemkin "0.1.6"]
[robert/hooke "1.3.0"]
[slingshot "0.10.3"]
[ring/ring-core "1.1.6"]
;[ring.middleware.logger "0.3.0"]
;[log4j "1.2.15"]
;[com.duelinmarkers/ring-request-logging "0.2.0"]
[ring-basic-authentication "1.0.1"]
[com.cemerick/friend "0.1.3"]
[cheshire "5.0.1"]
[compojure "1.1.3"]
[lib-noir "0.2.0"]
[ring/ring-jetty-adapter "1.1.5"]
[com.ashafa/clutch "0.4.0-RC1"]
[clj-http "0.6.1"]
[fs "1.3.2"]
[clj-stacktrace "0.2.4"]
[org.clojure/data.json "0.2.0"]
[clj-json "0.5.3"]
[com.cemerick/pomegranate "0.0.13"]
[com.datomic/datomic-free "0.8.3655"]
[zolodeck/demonic "0.1.0-SNAPSHOT"]
[zolodeck/zolo-utils "0.1.0-SNAPSHOT"]
[datomic-session "0.1.0"]
[conformity "0.1.0"]
[peridot "0.0.8"]
[fn.trace "1.3.0.2"]
[clj-base64 "0.0.2"]
[com.novemberain/langohr "1.0.0-beta10"] ;rabbitmq fun
]
:source-paths ["src"]
:test-paths ["test"]
:plugins [[lein-swank "1.4.4"]
[lein-ring "0.8.0"]
[lein-datomic "0.1.0"]]
:warn-on-reflection false
:main api.core
:ring {:handler api.core/app
:adapter {:port 9999}}
:datomic {:install-location "datomic-free/"
:config "resources/free-transactor.properties"
:db-uri "datomic:free://localhost:4334/group"
:schemas ["resources/schema" [
"schema.dtm"
]]}
:profiles {:shared {}
:dev [:shared {}]
:production [:shared ;; TODO: optimize for production environment?
{:offline? true}
;; https://github.com/weavejester/lein-ring#web-server-options
;; TODO: the production port is duplicated in api.core/-main - but actually read from the command line arguments (on production)
{:ring {:adapter {:port 4000}}}]})
(ns ring.middleware.json
(:use ring.util.response)
(:require [cheshire.core :refer :all]
[cheshire.generate :refer [add-encoder encode-str remove-encoder]])
)
(add-encoder java.net.URL encode-str)
(add-encoder java.net.URI encode-str)
(defn- json-request? [request]
(if-let [type (:content-type request)]
(not (empty? (re-find #"^application/(vnd.+)?json" type)))))
(defn- read-json [request & [keywords?]]
(if (json-request? request)
(if-let [body (:body request)]
(parse-string (slurp body) keywords?))))
(defn wrap-json-body
"Middleware that parses the :body of JSON requests into a Clojure data
structure."
[handler & [{:keys [keywords?]}]]
(fn [request]
(if-let [json (read-json request keywords?)]
(handler (assoc request :body json))
(handler request))))
(defn wrap-json-params
"Middleware that converts request bodies in JSON format to a map of
parameters, which is added to the request map on the :json-params and
:params keys."
[handler]
(fn [request]
(if-let [json (read-json request)]
(handler (-> request
(assoc :json-params json)
(update-in [:params] merge json)))
(handler request))))
(defn wrap-json-response
"Middleware that converts responses with a map or a vector for a body into a
JSON response."
[handler]
(fn [request]
(let [response (handler request)
body (:body response)]
(if (some #(% body) [seq? map? vector? set?])
(-> response
(content-type "application/json")
(update-in [:body] generate-string))
response))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.