Re: Continuing Google App Engine issues w/java.security.AccessControlException

232 views
Skip to first unread message

Paul Blair

unread,
Apr 1, 2011, 8:56:02 PM4/1/11
to Scalate
I think I have it figured out. Looking more closely at Yasushia's sample code (hello-scalate-appengine on github) I noticed that he's rendering the templates through the servlet.

I was able to get something quick and dirty working by removing the TemplateEngineFilter altogether and using the following code:

class Report extends HttpServlet {
   override def service(req: HttpServletRequest, res: HttpServletResponse) {
    render(req.getServletPath, req, res)
  }

  def render(servletPath: String, req: HttpServletRequest, res: HttpServletResponse) {
    val templateEngine = new TemplateEngine
    templateEngine.resourceLoader = new ServletResourceLoader(getServletContext)
    val context = new ServletRenderContext(templateEngine, req, res, getServletContext)
    context.include(servletPath + ".jade")
    res.setStatus(HttpServletResponse.SC_OK)
  }
}

From what I can tell from a brief look at the code, it seems that the TemplateEngineFilter always looks at the file system first even if the TemplateEngine is going to use the cached template later.  If that's the case, then folks who want to use Scalate with GAE shouldn't be using the TemplateEngineFilter.

On Fri, Apr 1, 2011 at 4:59 PM, Paul Blair <pbl...@cyrusinnovation.com> wrote:
I've read over the threads on this group regarding scalate on GAE but
still haven't managed to get things running. I have the App Engine SDK
installed, and when I run the development server and try to access a
template I get:

java.security.AccessControlException: access denied
(java.io.FilePermission /WEB-INF/index.ssp read)

I understand that this is because GAE doesn't allow file system
access, and that the answer is to precompile the templates.

I've mucked about with precompilation but no matter what I do, scalate
seems to want to look for the template file rather than pick up the
precompiled template class files.

Here's what I have:

web.xml has:

   <filter>
       <filter-name>TemplateEngineFilter</filter-name>
       <filter-
class>org.fusesource.scalate.servlet.TemplateEngineFilter</filter-
class>
   </filter>
   <filter-mapping>
       <filter-name>TemplateEngineFilter</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>

app-engine-web.xml has:

   <system-properties>
       <property name="scalate.allowReload" value="false"/>
       <property name="scalate.workdir" value="WEB-INF"/>
   </system-properties>

I also tried a system property of "precompiled!" -- a previous message
had listed it just above the system properties and it wasn't clear if
it was supposed to be a system property or not. At any rate, it made
no difference.

I have class files $_scalate_$index_ssp.class and $_scalate_$index_ssp
$.class . I've tried putting them in WEB-INF/classes, directly under
WEB-INF/ , in WEB-INF/scalate and in WEB-INF/_scalate but none of
these work.

When I precompiled the templates I used
org.fusesource.scalate.servlet.ServletRenderContext as the context
class; I had also tried org.fusesource.scalate.DefaultRenderContext
with no effect.

The class files look ok, but I also tried grabbing the compiled
template class files from the scalate-sample app and using them
instead, but that didn't work either.

I'm running out of ideas. Anyone?



--
Paul Blair
pbl...@cyrusinnovation.com

Cyrus Innovation LLC
200 Varick, Suite 902
New York, NY 10014
phone: (212) 647-7186
fax: (212) 591-6043
http://cyrusinnovation.com


Paul Blair

unread,
Apr 1, 2011, 4:59:29 PM4/1/11
to Scalate
Reply all
Reply to author
Forward
0 new messages