Binita Bharati
Binita Bharati

Reputation: 5898

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

Upvotes: 0

Views: 2102

Answers (2)

Nicolas Modrzyk
Nicolas Modrzyk

Reputation: 14187

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.

Upvotes: 1

ponzao
ponzao

Reputation: 20934

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

Upvotes: 1

Related Questions