         (error e "Couldn't reload:")
         e))))
 
+(defn ensure-dynamic-classloader
+  []
+  (let [thread (Thread/currentThread)
+        context-class-loader (.getContextClassLoader thread)
+        compiler-class-loader (.getClassLoader clojure.lang.Compiler)]
+    (when-not (instance? DynamicClassLoader context-class-loader)
+      (.setContextClassLoader
+        thread (DynamicClassLoader. (or context-class-loader
+                                        compiler-class-loader))))))
+
 (defn handle-signals
   "Sets up POSIX signal handlers."
   []

  "The configuration file loaded by the bin tool"
  (promise))

(defn set-config-file!
  "Sets the config file used by Riemann. Adds the config file's enclosing
  directory to the classpath as well."

        (run-tests-with-format test-name-pattern)))
    (run-tests-with-format test-name-pattern)))

(defn run-app!
  "Start Riemann with the given setup function. The setup function is responsible
  for executing code that you would normally put into your riemann.config file,
