Google App Engine JavaでFreeMarkerを使用しています。Google App Engine FreeMarkerテンプレートjava.security.AccessControlException
web.xml
<servlet>
<servlet-name>WebBookEditor</servlet-name>
<servlet-class>com.business.cloud.servlets.WebBookEditor</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WebBookEditor</servlet-name>
<url-pattern>/editor/*</url-pattern>
</servlet-mapping>
テンプレートパス:テンプレート
Template temp = cfg.getTemplate("/book_editor.ftlh”);
設定方法
private static void instantiateConfiguration() throws IOException {
if (null == cfg) {
cfg = new Configuration();
cfg.setDirectoryForTemplateLoading(new File("/templates"));
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
}
}
にウィルSをロードする/webapp/WEB-INF/templates/book_editor.ftlh
コード私が行方不明または間違っていることを特定するのを助けてください。次の例外が発生しています
Uncaught exception from servlet
java.security.AccessControlException: access denied ("java.io.FilePermission" "/templates" "read")
at com.google.appengine.runtime.Request.process-047aec732318c54c(Request.java)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:484)
at java.security.AccessController.checkPermission(AccessController.java:698)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at java.io.File.exists(File.java:877)
at freemarker.cache.FileTemplateLoader$1.run(FileTemplateLoader.java:124)
at java.security.AccessController.doPrivileged(AccessController.java:62)
at freemarker.cache.FileTemplateLoader.<init>(FileTemplateLoader.java:122)
at freemarker.cache.FileTemplateLoader.<init>(FileTemplateLoader.java:108)
at freemarker.template.Configuration.setDirectoryForTemplateLoading(Configuration.java:314)
at com.business.cloud.servlets.WebBookEditor.instantiateConfiguration(WebBookEditor.java:62)
at com.business.cloud.servlets.WebBookEditor.doGet(WebBookEditor.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:439)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:446)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:310)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:302)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:443)
at java.lang.Thread.run(Thread.java:745)
私はまだGoogleから聞いたことがなく、http://stackoverflow.com/questions/14209175/java-security-accesscontrolexception-access-denied-java-io-filepermissionを読んでいます。だから私は以下の提案を試みたが、運がない。 'web.xml'または' webapp'のパスに何かがまだ存在しない可能性はありますか? –