Making Clojure really work with Google App Engine

338 views
Skip to first unread message

Constantine Vetoshev

unread,
Sep 19, 2010, 9:10:05 PM9/19/10
to Clojure
I recently spent some time trying to abstract away some of the
incidental complexity of using Google App Engine with Clojure. Right
now, setting up interactive development and understanding what to do
requires reading several blog posts, and pasting in a lot of
boilerplate code. I ended up making a small library, called appengine-
magic, which cuts the boilerplate down to (1) a single additional .jar
dependency, (2) a couple of macros, and (3) a couple of files
generated by a Leiningen plugin. It takes a Ring handler, and turns it
into an application suitable for App Engine.

http://github.com/gcv/appengine-magic

It doesn't do everything yet, but I feel that it already makes a much
easier starting point than any alternative. The README file explains
the details.

Unfortunately, I hit a major stumbling block. Live deployment to App
Engine does not work because of a dependency importing a blacklisted
class.

appengine-magic expects to deploy a Ring handler. This makes it
possible to write apps using any Ring-compliant Clojure web framework.
In order to deploy to App Engine, it needs to turn the handler into a
servlet. The ring-servlet library does this with its handy
ring.util.servlet/defservice function. The implementation of
defservice uses duck-streams/copy. duck-streams imports
java.net.Socket, a class blacklisted by App Engine, causing deployment
to fail.

So any innocuous dependency, which transitively depends on anything
which loads a file which imports a blacklisted class, can cause
deployment to fail. Even Clojure itself is not entirely safe: for
example, duck-streams is now clojure.java.io, which imports
java.net.Socket.

I can reimplement defservice, and so avoid depending on ring-servlet.
Still, the situation seems fragile and precarious. Suggestions and
comments welcome.

Stefan Kamphausen

unread,
Sep 20, 2010, 9:17:07 AM9/20/10
to Clojure
Hi,

just a few days ago I started considering GAE for a (pet-)project.
Being able to develop in Clojure on GAE seems like a valuable goal to
me. For example, take a look at http://the-deadline.appspot.com which
was written that way.

So it might be a good idea to avoid creating threads automatically or
importing file/socket packages.

Anyway, just my 2ct.

Kind regards,
Stefan

Constantine Vetoshev

unread,
Sep 20, 2010, 4:03:52 PM9/20/10
to Clojure
On Sep 20, 9:17 am, Stefan Kamphausen <ska2...@googlemail.com> wrote:
> So it might be a good idea to avoid creating threads automatically or
> importing file/socket packages.

I think you're right. Dependencies are always a double-edged sword,
and in the case of App Engine, they are more toxic than usual. Anyway,
I eliminated the ring-servlet dependency, and appengine-magic now
successfully deploys simple "hello world" Ring applications. I'll send
a more formal announcement to the mailing list shortly.
Reply all
Reply to author
Forward
0 new messages