Reloading Clojure code in Tomcat

I have an existing Java webapp running in Tomcat, to which I add some primitive Clojure support. For the time being, I am simply including Clojure source files as resources in the class path and invoking it through clojure.lang.RT. This is primitive but works great.

However, I noticed that Tomcat WebappClassLoadercaches resources obtained through getResourceAsInputStream()that Clojure uses to extract and compile the source code. That is, it (require 'my-ns :reload)simply reloads the cached version of the file, even if an updated version is available on disk. Is there a way around or avoiding this caching for Clojure files?

The best I came up with after fruitless searches was to use reflection to manually delete a record from WebappClassLoader.resourceEntriesthat which is terrible.

Something is missing for me.

Answers like "using Jetty / Glassfish / JBoss", "restarting Tomcat", etc. not what i'm looking for.

+5
source share
4 answers

You cannot get around the behavior there WebappClassLoader. What you can do is move code downloading beyond its jurisdiction; for example $CATALINA_HOME/lib, as described here .

You will also need to move all your dependencies, leaving the .war file that you are actually deploying as webapp, in the form of a small shell that expects all the code to be available elsewhere.

WebappClassLoader, , , . ( , , IMO.)

+2

Clojure WEB-INF? , http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)

servletContext.getResourceAsStream("/WEB-INF/foo/core.clj");

Groovy Tomcat.

0

cachingAllowed, ? .

0

clojure, - :

(io/input-stream (io/resource "bla.clj"))

, .

0

All Articles