2

I'm just beginning with clojure and I'm trying to build a small web app. I wanted to try out hiccup but it doesn't seem to be working. My code is below.

Project.clj

    (defproject WebTest "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [compojure "1.1.5"]
                 [hiccup "1.0.3"]
                 [org.clojure/java.jdbc "0.2.3"]
                 [net.sourceforge.jtds/jtds "1.2.4"]
                 ]
  :plugins [[lein-ring "0.8.2"]
            [lein-idea "1.0.1"]]
  :ring {:handler WebTest.handler/app}
  :profiles
  {:dev {:dependencies [[ring-mock "0.1.3"]]}})

handler.clj

    (ns WebTest.handler
  (:use compojure.core)
  (:require [compojure.handler :as handler]
            [compojure.route :as route]
            [WebTest.Content :as pages]
            [hiccup.core :as templ]))

(defroutes app-routes
  (GET "/" [] (templ/html [h1 "Hello world"]))
  (GET "/Greeting/:name" [name] (str "<h1>Hello " name "</h1>"))
  (GET "/Date/:year/:month/:day" [year month day] (str "<h1>It is " month "/" day "/" year "</h1>"))
  (route/not-found "Not Found"))

(def app
  (handler/site app-routes))

And the error that I get is

Exception in thread "main" java.io.FileNotFoundException: Could not locate hiccu
p/core/as__init.class or hiccup/core/as.clj on classpath:
        at clojure.lang.RT.load(RT.java:432)
        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)

A very long stack trace follows that. Any insight into what I'm doing wrong?

Seth Paulson
  • 800
  • 6
  • 15

1 Answers1

3

Attempting to require WebTest.Content as you do fails for me, Though the rest works fine if I remove that one:

(ns WebTest.handler
  (:use compojure.core)
  (:require [compojure.handler :as handler]
            [compojure.route :as route]
            ;[WebTest.Content :as pages]
            [hiccup.core :as templ])) 

The error you mention would be the case if there where mismatched []s in the :require section of handler.clj's ns form though they are not caused by it as you show it.

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284
  • That was a reference to another file that was not actually being used. I removed it and I still get the same error. – Seth Paulson Apr 08 '13 at 20:54
  • 2
    I have to agree with Arthur, Clojure is trying to find an "as" file in under the hiccup.core namespace. This would make me think that a ":" is missing from in front of a keyword. – Mike Apr 08 '13 at 23:49
  • Ok well I moved it from the bottom to the top and it started working. And then back down to the bottom and it still worked. No idea why that helped :( – Seth Paulson Apr 09 '13 at 15:33