I'm a relative newcomer to Clojure, and I'm puzzled by problems I have
using extend in a webapp. Any help would be hugely appreciated.
My use case is basically this:
(defrecord FooRecord [msg])
(defprotocol FooProtocol
(bar [foo] "to use with extend-type"))
(extend FooRecord
FooProtocol
{:bar (fn [foo] (str "Test " (:msg foo)))})
I'm calling bar on a newly created FooRecord:
(bar (->FooRecord "Successful"))
This works in a REPL, and also works great in a web application on ring
server-headless:
Test Successful
But the moment I package the code in a war and deploy to Jetty 8 or Tomcat
7, it fails:
java.lang.IllegalArgumentException: No implementation of method: :bar
> of protocol: #'extend-test.core.handler/FooProtocol found for class:
> extend_test.core.handler.FooRecord
> clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:544)
>
> extend_test.core.handler$eval44$fn__45$G__35__50.invoke(handler.clj:8)
> extend_test.core.handler$fn__65.invoke(handler.clj:16)
> compojure.core$make_route$fn__1431.invoke(core.clj:104)
> ...
I searched this group and the web for clues. It smells of a
classloading/aliasing problem, but I could not find any information to
indicate that this behaviour is expected when deploying to a servlet
container, or what I can do about it apart from avoid using extend.
If you'd like to check out the full code or run it yourself, I've created a
Github project with a minimal test case
<https://github.com/pdenhaan/extend-test>.
The problem has me altogether stumped for the moment. Thanks for reading.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.