Hiccup not working : FileNotFoundException: Could not locate ../as__init.class or ../as.clj on classpath

StackOverflow https://stackoverflow.com/questions/15888321

  •  02-04-2022
  •  | 
  •  

Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top