Just FYI (and you probably already know this David), most of the clojure.lang.RT class is considered an implementation detail and is subject to change without notice. I believe 1.6 will bring a new API that is intended to provide a supported way to embed Clojure into JVM-based applications.
Based on posts I've seen on the mailing lists from Clojure/core folks, I've restricted my use to just RT.var() and I load source files like this: RT.var( "clojure.core", "load" ).invoke( filepath ); RT.var( "my.namespace", "my-fun" ).invoke( 1, 2, 3 ); // (my.namespace/my-fun 1 2 3) RT.var( "my.namespace", "my-var" ).deref(); // access my.namespace/my-var directly // same as (deref #'my.namespace/my-var) I haven't pushed too much at the boundaries of classloaders tho' so there may well be dragons there, but the above works for me for embedding Clojure in an existing JVM-based web application. Sean On Tue, Aug 20, 2013 at 1:35 PM, David Pollak <feeder.of.the.be...@gmail.com> wrote: > Howdy, > > I have an application where I need multiple independent Clojure contexts > running in the same JVM. > > I've played around with a custom classloader, but when I try to eval code > (calling RT.eval.invoke via reflection), I wind up with: > > java.lang.ClassCastException: clojure.core$eval1 cannot be cast to > clojure.lang.IFn > > > It seems that someplace the clojure.lang.IFn interface is being loaded > around my classloader. > > Can someone point me to a way to run multiple Clojure contexts in the same > JVM? > > Thanks, > > David > > PS -- Interestingly, invoking RT.loadResourceScript via reflection works > just fine... so my current workaround is to do that... but it's less than > optimal. > > -- > Telegram, Simply Beautiful CMS https://telegr.am > Lift, the simply functional web framework http://liftweb.net > Follow me: http://twitter.com/dpp > Blog: http://goodstuff.im > > -- > -- > 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 > --- > 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 clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.