I spot invalid let here: (defn get-a-member [id] (let [id (parse-int id) member] [member (memberdb/get-member id)]
should be (defn get-a-member [id] (let [id (parse-int id) member (memberdb/get-member id)] On Sunday, February 16, 2014 4:01:03 AM UTC+2, The Dude (Abides) wrote: > > Thanks, here's the entire stack trace: > > java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to > clojure.lang.IFn > members.clj:33 sikhpyar.routes.members/get-member > members.clj:50 sikhpyar.routes.members/fn > core.clj:94 compojure.core/make-route[fn] > core.clj:40 compojure.core/if-route[fn] > core.clj:25 compojure.core/if-method[fn] > core.clj:107 compojure.core/routing[fn] > core.clj:2443 clojure.core/some > core.clj:107 compojure.core/routing > RestFn.java:139 clojure.lang.RestFn.applyTo > core.clj:619 clojure.core/apply > core.clj:112 compojure.core/routes[fn] > core.clj:107 compojure.core/routing[fn] > core.clj:2443 clojure.core/some > core.clj:107 compojure.core/routing > RestFn.java:139 clojure.lang.RestFn.applyTo > core.clj:619 clojure.core/apply > core.clj:112 compojure.core/routes[fn] > middleware.clj:17 > sikhpyar.middleware/template-error-page[fn] > middleware.clj:10 sikhpyar.middleware/log-request[fn] > middleware.clj:44 > noir.util.middleware/wrap-request-map[fn] > keyword_params.clj:32 > ring.middleware.keyword-params/wrap-keyword-params[fn] > nested_params.clj:70 > ring.middleware.nested-params/wrap-nested-params[fn] > params.clj:58 ring.middleware.params/wrap-params[fn] > middleware.clj:12 hiccup.middleware/wrap-base-url[fn] > multipart_params.clj:107 > ring.middleware.multipart-params/wrap-multipart-params[fn] > validation.clj:153 > noir.validation/wrap-noir-validation[fn] > cookies.clj:72 noir.cookies/noir-cookies[fn] > cookies.clj:171 > ring.middleware.cookies/wrap-cookies[fn] > session.clj:142 noir.session/noir-flash[fn] > flash.clj:31 ring.middleware.flash/wrap-flash[fn] > session.clj:97 noir.session/noir-session[fn] > session.clj:85 > ring.middleware.session/wrap-session[fn] > Var.java:415 clojure.lang.Var.invoke > reload.clj:18 ring.middleware.reload/wrap-reload[fn] > stacktrace.clj:17 > ring.middleware.stacktrace/wrap-stacktrace-log[fn] > stacktrace.clj:80 > ring.middleware.stacktrace/wrap-stacktrace-web[fn] > jetty.clj:18 ring.adapter.jetty/proxy-handler[fn] > (Unknown Source) > ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle > HandlerWrapper.java:116 > org.eclipse.jetty.server.handler.HandlerWrapper.handle > Server.java:363 org.eclipse.jetty.server.Server.handle > AbstractHttpConnection.java:483 > org.eclipse.jetty.server.AbstractHttpConnection.handleRequest > AbstractHttpConnection.java:920 > org.eclipse.jetty.server.AbstractHttpConnection.headerComplete > AbstractHttpConnection.java:982 > org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete > HttpParser.java:635 > org.eclipse.jetty.http.HttpParser.parseNext > HttpParser.java:235 > org.eclipse.jetty.http.HttpParser.parseAvailable > AsyncHttpConnection.java:82 > org.eclipse.jetty.server.AsyncHttpConnection.handle > SelectChannelEndPoint.java:628 > org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle > SelectChannelEndPoint.java:52 > org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run > QueuedThreadPool.java:608 > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob > QueuedThreadPool.java:543 > org.eclipse.jetty.util.thread.QueuedThreadPool$3.run > Thread.java:744 java.lang.Thread.run > > Here's the route function: > > (defn get-a-member [id] > (let [id (parse-int id) member] > [member (memberdb/get-member id)] > (session/put! :member-id (member :id)) > (session/put! :nexto (+ (member :id) 1)) > (session/put! :username (member :username)) > (session/put! :firstname (member :firstname)) > (session/put! :lastname (member :lastname)) > (session/put! :email (member :email)) > (layout/render "member/profile2.html" {:member member}))) > > The route: > > (GET "/member/:id" [id] (get-a-member id)) > > The model: > > (defmulti parse-int type) > (defmethod parse-int java.lang.Integer [n] n) > (defmethod parse-int java.lang.String [s] (Integer/parseInt s)) > > (defn get-member [id] > (let [id (parse-int id)] > (jdbc/query db ["SELECT * FROM members WHERE id = ? LIMIT 1" id]))) > > I'm using parse-int to explicitly specify id as an integer. > > If I use just the query with no output to layout, or sessions, etc, it > does show the output from the db. > > If I put just (str id) on the route handler, it does show the number of > the id. > > So for sure the url is passing the id number and the db connection is > fine. Am trying this with java.jdbc 0.3.3 and postgres 8.4-702.jdbc4 > driver. I had the version 9 before but I don't think the problem is the db > driver. Appreciate any pointers. > > One other thing, if I use Korma everything works fine but if I use > raw-exec it doesn't work. I tried Korma in a separate duplicate of this > project to avoid any conflict with java.jdbc 0.3.3. > > I don't mind using a dsl but I'd really like to have access to raw sql as > and when needed to take advantage of years of writing sql, which to me is a > very pleasant dsl itself to interact with a db. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.