I'm trying to deploy a simple test app to Google App Engine. It's written in clojure and use mongodb(MongoHq) internally. Though it works well in my local machine, it doesn't work in Google App Engine, internal server error occurred.
I use monger to use mongodb, and connect by using connect-via-uri
function.
(mg/connect-via-uri config/db-uri)
When I delete the above code, no error occurred.
My question is: Is it possible (or allowed) to use(=connect) MongoHq in Google App Engine?
I check the logs and the stack trace is like this:
Uncaught exception from servlet
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
at java.security.AccessController.checkPermission(AccessController.java:565)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:56)
at com.google.apphosting.runtime.security.CustomSecurityManager.checkAccess(CustomSecurityManager.java:131)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
at java.lang.Thread.init(Thread.java:378)
at java.lang.Thread.<init>(Thread.java:527)
at com.mongodb.DBTCPConnector$DefaultThreadFactory.newThread(DBTCPConnector.java:680)
at java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:591)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:922)
at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1591)
at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:305)
at java.util.concurrent.ScheduledThreadPoolExecutor.scheduleAtFixedRate(ScheduledThreadPoolExecutor.java:542)
at com.mongodb.DefaultServer.<init>(DefaultServer.java:57)
at com.mongodb.DefaultClusterableServerFactory.create(DefaultClusterableServerFactory.java:50)
at com.mongodb.BaseCluster.createServer(BaseCluster.java:200)
at com.mongodb.SingleServerCluster.<init>(SingleServerCluster.java:45)
at com.mongodb.Clusters.create(Clusters.java:37)
at com.mongodb.DBTCPConnector.start(DBTCPConnector.java:80)
at com.mongodb.Mongo.<init>(Mongo.java:346)
at com.mongodb.Mongo.<init>(Mongo.java:327)
at com.mongodb.MongoClient.<init>(MongoClient.java:268)
at monger.core$connect_via_uri.invoke(core.clj:159)
at xxx.handler$init.invoke(handler.clj:17)
at xxx.listener$_contextInitialized.invoke(listener.clj:1)
at xxx.listener.contextInitialized(Unknown Source)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:199)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:174)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:134)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:446)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:724)
Unforunatly monger is attempting to create a new thread, and GAE only allows a single thread which can frustrate Clojure developers a bit It's unlikely that mongo can be made to work with App Engine. GAE is opinionated in it's choice of datastores.