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

对着背影说爱祢 提交于 2019-12-23 04:22:52

问题


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

回答1:


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).




回答2:


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, i.e CSS, Images, Javascripts etc ...

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



来源:https://stackoverflow.com/questions/19196745/clojure-clostache-error-no-implementation-of-method-make-reader-of-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!