Appengine & Clojure

39 views
Skip to first unread message

Sam Newman

unread,
Feb 7, 2010, 12:36:21 PM2/7/10
to Compojure
Hi all,

I'm trying to get a relatively simple Clojure app working under
Google's appengine - specifically the local SDK. The problem is that
gae applications have limitations placed upon them, prohibiting
certain activities like starting threads. I'm struggling with the fact
that the latest version of compojure, seems to require access to
jetty, even when running inside another container. This is the simple
servlet code:

(ns org.superapp
(:gen-class :extends javax.servlet.http.HttpServlet)
(:use compojure))

(defroutes my-app
(GET "/"
(html [:h1 "Hello World"]))
(ANY "*"
(page-not-found)))

(defservice my-app)

When I fire the appengine SDK up against this code, if I don't include
jetty I get a ClassNotFoundException, but if I do, I get the following
security exception:

java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.RT.classForName(RT.java:1487)
at clojure.core$import__4028.doInvoke(core.clj:1856)
at clojure.lang.RestFn.invoke(RestFn.java:458)
at compojure.server.jetty__init.load(Unknown Source)
at compojure.server.jetty__init.(Unknown Source)
at java.lang.Class.forName0(Native Method)

<snip>

Caused by: java.security.AccessControlException: access denied
(java.lang.RuntimePermission modifyThreadGroup)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:
323)
at
java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:
532)
at com.google.appengine.tools.development.DevAppServerFactory
$CustomSecurityManager.checkPermission(DevAppServerFactory.java:151)
at com.google.appengine.tools.development.DevAppServerFactory
$CustomSecurityManager.checkAccess(DevAppServerFactory.java:176)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:288)
at java.lang.Thread.init(Thread.java:332)
at java.lang.Thread.(Thread.java:379)
at org.mortbay.jetty.Server$ShutdownHookThread.(Server.java:461)
at org.mortbay.jetty.Server$ShutdownHookThread.(Server.java:461)
at org.mortbay.jetty.Server.(Server.java:53)
... 94 more

Now, AFAIK, my code isn't doing anything with Jetty, but it seems as
though some part of the compojure internals assume jetty is available,
and tries to do something with it which attempts to start threads.

I know in the past that people have managed to get this working:
http://elhumidor.blogspot.com/2009/04/clojure-on-google-appengine.html
but that was a while ago.

Any thoughts?

Sam Newman

Joshua Herman

unread,
Feb 7, 2010, 12:59:30 PM2/7/10
to comp...@googlegroups.com

downgrade gae to 1.2 or 1.2.2


--
You received this message because you are subscribed to the Google Groups "Compojure" group.
To post to this group, send email to comp...@googlegroups.com.
To unsubscribe from this group, send email to compojure+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/compojure?hl=en.

James Reeves

unread,
Feb 7, 2010, 4:00:56 PM2/7/10
to Compojure
On Feb 7, 12:36 pm, Sam Newman <sam.new...@gmail.com> wrote:
> I'm trying to get a relatively simple Clojure app working under
> Google's appengine - specifically the local SDK. The problem is that
> gae applications have limitations placed upon them, prohibiting
> certain activities like starting threads. I'm struggling with the fact
> that the latest version of compojure, seems to require access to
> jetty, even when running inside another container. This is the simple
> servlet code:
>
> (ns org.superapp
>   (:gen-class :extends javax.servlet.http.HttpServlet)
>   (:use compojure))

You should be able to replace the (:use compojure) clause, which pulls
in everything, with more specific library calls. For example:

(ns org.superapp
  (:gen-class :extends javax.servlet.http.HttpServlet)

  (:use [compojure.http servlet routes])
(:use compojure.html))

If you avoid the compojure.server.jetty library, you should be okay.

- James

atreyu

unread,
Feb 28, 2010, 1:39:54 PM2/28/10
to Compojure
> You should be able to replace the (:use compojure) clause, which pulls
> in everything, with more specific library calls. For example:
>
> (ns org.superapp
>   (:gen-class :extends javax.servlet.http.HttpServlet)
>   (:use [compojure.http servlet routes])
>   (:use compojure.html))
>
> If you avoid the compojure.server.jetty library, you should be okay.
>
> - James

thanks a lot! works fine with my exception:
java.rmi.server.UID is a restricted class.
and limiting the ns used i have the hello world

i suppose i`ll get the exception in future :-/

Reply all
Reply to author
Forward
0 new messages