Hi, I'm working on a "proxying JDBC driver" in Clojure [1]. Everything is working fine. But I had one problem with the way Clojure (i.e. clojure.lang.RT) manages its classloader.
When Wildfly loads my UBERJAR which contains Clojure and loads/instanciates my gen-class `buttle.jdbc.Driver` then its static initializer will load `clojure.lang.RT`. At this point the current thread's context classloader (TCCL; which is put into place by Wildfly) does NOT point to the one that is loading my code and the TCCL in-fact does not "see" my classes. So when Clojure/RT then tries to find `clojure/core.clj` it fails because Clojure uses the TCCL for loading [2]. I could try to set `clojure.core/*use-context-classloader*` to false but this leads to a chicken-egg-problem since for doing that, `clojure.lang/RT` would have to be loaded in the first place. So my question is: is there a nice way out of this? The workaround I came up with was to compile a Java class [3] which is the super class of my gen class [4]. And since static initializers are called in order super-class->derived-class the static initializer of the super-class is used to set the TCCL to the one that loads my code base. After that Clojure finds clojure/core.clj without problems. Any ideas on how to do without this hack? Henrik [1] https://github.com/henrik42/buttle/ [2] https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L2174 [3] https://github.com/henrik42/buttle/blob/master/java/buttle/SetContextClassLoaderInStaticInitializer.java [4] https://github.com/henrik42/buttle/blob/master/src/buttle/driver.clj#L29 -- 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/d/optout.