简体   繁体   中英

Clojure Clostache error - No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil

Am using clojure - 1.5.1, compojure - 1.1.5, clostache - 1.3.1.

The template file is present under resources/public/templates folder.

Code :

(:require [clostache.parser :as cp])

(cp/render-resource "templates/connectionDetails.mustache" {:jmsConnectionName "Michael" :rest-conn-names ["a" "b"]}))

The call to Clostache's render-resource is throwing the below Exception :

Exception: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
                  core_deftype.clj:541 clojure.core/-cache-protocol-fn
                             io.clj:73 clojure.java.io/fn[fn]
                            io.clj:106 clojure.java.io/reader
                       RestFn.java:410 clojure.lang.RestFn.invoke
                          AFn.java:161 clojure.lang.AFn.applyToHelper
                       RestFn.java:132 clojure.lang.RestFn.applyTo
                          core.clj:619 clojure.core/apply
                         core.clj:6278 clojure.core/slurp
                       RestFn.java:410 clojure.lang.RestFn.invoke
                        parser.clj:396 clostache.parser/render-resource

The resource is probably not found because your path seems to be incorrect. resources is added to the classpath so to access your template you should use "public/templates/connectionDetails.mustache" (it might not make sense to have the templates under public if you do not expose them directly from your application).

Your templates should be located under the source folder. In your case that would be:

src
|
- templates
  |
  - connectionDetails.mustache

The public folder is used for HTML resources pulled from the web application client, ie CSS, Images, Javascripts etc ...

Clostache is looking at your classpath (ie src folder) to find the files it needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM