Fun with Clojure and Lucee

Since we have Lucee available on a Maven repo as a set of JARs and dependencies, I figured I’d see what it would take to use Lucee as a dependency in a Clojure application…

https://github.com/seancorfield/clojure-lucee

All you need is Leiningen - Clojure’s build tool - installed and you can spin up a Clojure-based web app that can run CFML pages :slight_smile:

Now, there’s some caveats here! It uses the Lucee CLI to “run” the CFML pages and captures the output and sends it to the browser. That means that every request is a new session. I could probably fix that by passing cookies into the CLI since it looks like it supports that. It also means there’s no communication between the Clojure code and the CFML code (but that’s kinda clean and functional).

Deeper integration is possible, of course, since Lucee is a set of libraries that can be called from Java or Clojure or… Having the artifacts available for Maven-like tools is really nice!

Micha mentioned JSR-223 and I’m very much looking forward to what that brings - since it would allow CFML to be used as an embedded scripting language inside other applications (written in Java or Clojure or…).

Sean Corfield – (904) 302-SEAN
An Architect’s View – http://corfield.org/

“Perfection is the enemy of the good.”
– Gustave Flaubert, French realist novelist (1821-1880)

After a bit of experimentation, I managed to tie the CFML session scope to the Clojure Ring session ID (using session fixation via the URL parameters passed to the CLI). And I made cookies transfer across from Clojure (Ring) to CFML as well.

So I updated the example to show session scope and cookies both working. Note that cookie scope is essentially readonly in the CFML page since cookies are only passed in not out.

Sean Corfield – (904) 302-SEAN
An Architect’s View – http://corfield.org/

“Perfection is the enemy of the good.”
– Gustave Flaubert, French realist novelist (1821-1880)On Feb 7, 2015, at 3:54 PM, Sean Corfield <@Sean_Corfield> wrote:

Now, there’s some caveats here! It uses the Lucee CLI to “run” the CFML pages and captures the output and sends it to the browser. That means that every request is a new session. I could probably fix that by passing cookies into the CLI since it looks like it supports that.