For others who might have this problem, I've reduced this to the following:
(defrecord A ...) (instance? A (A. ...)) ;=> true (instance? A (map->A {...})) ;=> can be false (e.g., in a tomcat servlet) The map->A constructor uses the create method, and as Chris said earlier, this seems to have to do with some deep class loading magic. But this strikes me as a bug in the sense that the above should under all circumstances be a guarantee made by map->A. On Thursday, December 13, 2012 11:49:20 PM UTC-5, CGAT wrote: > > I've now put :aot [ns1] in the projects.clj, did lein compile, then lein > ring uberwar. > There was no difference. The class loaders are distinct and instance? > still returns false. > > 1. Did I do the AOT compile incorrectly? Is it even necessary? > (The class files are in the war file but *all* of them are, not just > ns1.) > 2. If not, is it not being ``transmitted'' correctly into the war file? > 3. Or, am I misunderstanding the problem? > > I'm really not clear how to fix this. A record constructed with > the map->A constructor does not show up as being an instance of A. > Why? > > Help!? > > On Thursday, December 13, 2012 11:13:29 PM UTC-5, CGAT wrote: >> >> Without AOT, the classLoader's are not the same >> >> (str (.getClassLoader A)) >> >> WebappClassLoader >> delegate: false >> repositories: >> /WEB-INF/classes/ >> ----------> Parent Classloader: >> org.apache.catalina.loader.StandardClassLoader@790bc49d >> >> (str (.getClassLoader (class an-A-record))) >> clojure.lang.DynamicClassLoader@3ac803e6 >> >> I'll try AOT compile next, as that DynamicClassLoader seems to suggest. >> But I'm not sure what else can be done. >> >> >> On Thursday, December 13, 2012 10:53:53 PM UTC-5, CGAT wrote: >>> >>> I did not AOT compile it, though I can try that. I'll check the >>> ClassLoader as well, thanks. I do know that (class an-A-record) is A, >>> suitably ns-qualified. >>> >>> Thanks for the ideas. What did you finally do when this happened to you? >>> >>> On Thursday, December 13, 2012 8:19:48 PM UTC-5, cjeris wrote: >>>> >>>> In the Tomcat uberwar setting, is ns1 AOT-compiled? Are >>>> (.getClassLoader A) and (.getClassLoader (.getClass an-A-record)) >>>> different >>>> class loaders? That's what the problem was when this one bit me. I never >>>> did track down exactly why it happens or how to fix it. >>>> >>>> peace, Chris Jeris >>>> >>>> On Thu, Dec 13, 2012 at 6:13 PM, CGAT <genov...@gmail.com> wrote: >>>> >>>>> I have a frustrating situation and would appreciate any help. >>>>> The call >>>>> >>>>> (instance? A an-A-record) >>>>> >>>>> is returning false when an-A-record is in fact an instance of A. >>>>> >>>>> This is in a noir/compojure/ring server. But the problem *only* *occurs >>>>> >>>>> *when run under tomcat, *not* when run under Jetty. I'm guessing >>>>> that I've missed declaring something properly, but I don't see what it >>>>> is. >>>>> (I hope this is a suitable forum for this question.) >>>>> >>>>> Here's the situation in more detail. >>>>> >>>>> In ns1 >>>>> >>>>> (defrecord A ...) >>>>> (defrecord B ...) >>>>> (defn AorB? [x] (or (instance? A x) (instance? B x))) >>>>> (defn Afactory [] ...) ; makes an A >>>>> >>>>> In ns2, which :require's ns 1 refering AorB? and Afactory and >>>>> :imports A and B properly from ns1. >>>>> >>>>> (AorB? (Afactory)) ;=> true in jetty, false in tomcat >>>>> >>>>> I'm using Clojure 1.4.0, compojure 1.1.3, noir 1.3.0-beta10, .... >>>>> I use lein run to start the jetty server (with a suitable -main), >>>>> and lein ring uberwar to create a warfile which runs under >>>>> Apache Tomcat 6.0.24 (with JVM 1.6.0_26-b03). >>>>> All the rest of the code appears to be behaving identically under >>>>> either platform. >>>>> >>>>> I've been banging my head against the wall over this and would >>>>> appreciate any help or pointers. Thanks! >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Clojure" group. >>>>> To post to this group, send email to clo...@googlegroups.com >>>>> Note that posts from new members are moderated - please be patient >>>>> with your first post. >>>>> To unsubscribe from this group, send email to >>>>> clojure+u...@googlegroups.com >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/clojure?hl=en >>>> >>>> >>>> >>>> >>>> -- >>>> Chris Jeris >>>> cje...@brightcove.com (617) 686-3271 >>>> freenode/twitter/github: ystael >>>> >>>> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en