branaway / Japid

A Java-based statically-typed fast template engine that can be used in any Java code. It has special adapter for use with the Play! Framework.
113 stars 18 forks source link

Access denied when starting up on GAE #11

Closed mrcritical closed 13 years ago

mrcritical commented 13 years ago

After deploying to GAE using the GAE module with Japid I receive the following exception at startup. I ran japid:regen before deploying. I'm using Japid 0.8.4.3.

Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@114a306{/,/base/data/home/apps/test/2.351048128178089005} java.lang.RuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission app/japidviews/_javatags write) at cn.bran.play.JapidCommands.reloadChanged(JapidCommands.java:200) at cn.bran.play.JapidCommands.reloadChanged(JapidCommands.java:289) at cn.bran.play.JapidPlugin.beforeDetectingChanges(JapidPlugin.java:66) at cn.bran.play.JapidPlugin.onLoad(JapidPlugin.java:45) at play.plugins.PluginCollection.initializePlugin(PluginCollection.java:186) at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:120) at play.Play.init(Play.java:273) at play.server.ServletWrapper.contextInitialized(ServletWrapper.java:71) 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:191) at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:168) at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123) at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:260) at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9669) at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:439) at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:573) at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448) at com.google.tracing.TraceContext.runInContext(TraceContext.java:688) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318) at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:636) Caused by: java.security.AccessControlException: access denied (java.io.FilePermission app/japidviews/_javatags write) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:355) at java.security.AccessController.checkPermission(AccessController.java:567) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:45) at java.lang.SecurityManager.checkWrite(SecurityManager.java:979) at java.io.File.mkdir(File.java:1233) at java.io.File.mkdirs(File.java:1262) at cn.bran.play.JapidCommands.mkdir(JapidCommands.java:54) at cn.bran.play.JapidCommands.reloadChanged(JapidCommands.java:198) ... 28 more

branaway commented 13 years ago

Hi thanks for reporting.

Honestly I have not used GAE before so I'll need to a little time to investegate that.

The exception was thrown when Japid was trying to create the required japidview/_javatags directory. I was curious why this happened. Can you check that the required japidviews tree is fully populated and all the templates are all converted to Java code before you deploy to GAE?

I don't know much about GAE, yet. Does it allow you to run your application in dev mode or you have to precompile everythig before deployment and run it in prod mode only?

While I'm looking this, perhaps you can post the issue to the mail list and see if any other people are using Japid with GAE.

I do want to make sure Japid works with GAE since Japid seems to be a good fit for this resource-constrained runtime.

branaway commented 13 years ago

My understanding is that GAE does not allow any writing to the file system. Japd however need to write when it detects changes to the template in DEV mode.

mrcritical commented 13 years ago

I agree Japid and GAE are a perfect match. And yes, the japidview tree is present and populated with .html and .java files before deploying. I opened the war directory generated by play for deploy and japidviews, including _javatags and other templates are in the precompiled folder.

As to GAE, play forces it into PROD mode because everything must be precompiled as it does not allow writing, as you noted. The play GAE module performs a full compile when generating the war file.

Here is a snippet from the startup log on GAE:

I 2011-06-10 19:43:39.793 play.Logger info: Play! is running in Google App Engine I 2011-06-10 19:43:40.243 play.Logger info: Starting /base/data/home/apps/test/2.351049204618356243/WEB-INF/application W 2011-06-10 19:43:40.243 play.Logger warn: No tmp folder will be used (cannot create the tmp dir) I 2011-06-10 19:43:40.248 play.Logger info: Module gae is available (/base/data/home/apps/test/2.351049204618356243/WEB-INF/application/modules/gae-1.4) I 2011-06-10 19:43:40.249 play.Logger info: Module router is available (/base/data/home/apps/test/2.351049204618356243/WEB-INF/application/modules/router-1.0) I 2011-06-10 19:43:40.249 play.Logger info: Module siena is available (/base/data/home/apps/test/2.351049204618356243/WEB-INF/application/modules/siena-2.0.0) I 2011-06-10 19:43:40.250 play.Logger info: Module secure is available (/base/data/home/apps/test/2.351049204618356243/WEB-INF/application/modules/secure) I 2011-06-10 19:43:40.641 play.Logger info: Detected that plugin 'play.modules.gae.GAEPlugin@15a4523' disabled the plugin 'play.jobs.JobsPlugin@172c47b' the old way - should use Play.disablePlugin() I 2011-06-10 19:43:41.025 play.Logger info: Application is precompiled D 2011-06-10 19:43:41.902 play.Logger debug: Siena DB Type: GAE I 2011-06-10 19:43:41.992 play.Logger info: Application 'test' is now started ! I 2011-06-10 19:43:41.992 play.Logger info: Forcing PROD mode because deploying as a war file. I 2011-06-10 19:43:42.090 This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

I'll post my issue in the forums, though I saw someone else say that had it work in play 1.1. I'm trying this with 1.2.1. Worth seeing what happens.

branaway commented 13 years ago

Hi,

Can you grab the jars in https://github.com/branaway/Japid/tree/master/lib and test it again? I have disabled any writing activities of Japid in PROD mode. Not tested in GAE though since I haven't started on GAE yet:)

branaway commented 13 years ago

I think that's it. I have uploaded the module of version 0.8.4.5 to the module repo. Can you check it out?

This is a test app with Japid: curl http://bb55rr2.appspot.com/products/indexj?n=30

mrcritical commented 13 years ago

Yup, that did it. Works me too! Thanks for the very quick turn around and this great template language. Very good work.