开发者

Weird lein uberwar behavior

开发者 https://www.devze.com 2023-03-10 22:35 出处:网络
I\'m executing lein uberwar for my test webapp and I\'m getting the following weird error: Exception in thread \"main\" java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.

I'm executing lein uberwar for my test webapp and I'm getting the following weird error:

Exception in thread "main" java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol (servlet.clj:1)

The servlet.clj contains the following:

(ns test.servlet
  (:use ring.util.servlet)
  (:require test.routes :as routes)
  (:gen-class :extends javax.servlet.http.HttpServlet))

(defservice routes/app-routes)

The test.routes file contains:

(ns test.routes
  (:use compojure.core)
  (:require [compojure.route :as route]
            [compojure.handler :as handler]))


(defroutes app-routes
  (GET "/" [] {:status 200
               :headers {"Content-Type" "text/html"}
               :body "<h1>Hello World</h1>"})
  (route/files "/" {:root "static"})
  (ANY "/:s" [s] (str "page-not-found" s)

;; For lein ring-server
;(def test-handler
;  (handler/site app-routes))

The strange thing i开发者_StackOverflow中文版s that if I substitute the line

(:require test.routes :as routes)

With:

(:require test.routes)

And call

 (defservice test.routes/app-routes)

In servlet.clj, the WAR compiles fine and it is working flawlessly in tomcat. Is there some bug in my code that I fail to see? Why do I need to call test.routes/... instead of just routes/...?


You need to put it inside a vector:

(:require [test.routes :as routes])
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号