java – 使用Google App Engine初始化Freemarker时出现IllegalAccessError

我正在尝试使用带有GAE 1.7.1的Freemarker 2.3(我还使用1.8.1.1进行了一些测试)但是当Freemarker初始化时我发生了一个非常奇怪的错误:

java.lang.IllegalAccessError: Class
   com.google.appengine.tools.development.agent.runtime.Runtime can not access
   a member of class freemarker.log.Log4JLoggerFactory with modifiers ""
at freemarker.log.Logger.createFactory(Logger.java:335)
at freemarker.log.Logger.createFactory(Logger.java:304)
at freemarker.log.Logger.selectLoggerLibrary(Logger.java:163)
at freemarker.log.Logger.getLogger(Logger.java:266)
at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:69)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:69)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at freemarker.template.ObjectWrapper.<clinit>(ObjectWrapper.java:69)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:69)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at freemarker.core.Configurable.<init>(Configurable.java:139)
at freemarker.template.Configuration.<init>(Configuration.java:142)
at freemarker.template.Configuration.<clinit>(Configuration.java:127)

它在实例化Configuration对象时发生:

Configuration configuration = new Configuration();

我尝试使用Logger.selectLoggerLibrary调用更改底层记录器,但我有类似的东西……

非常感谢您的帮助.

解决方法:

尝试使用Logger.selectLoggerLibrary选择LIBRARY_SLF4J或LIBRARY_COMMONS.这个问题会消失吗?

更新:我明白为什么它在GAE上用于Log4J.将在2.3.20-gae修复.

上一篇:网页静态化技术--Freemarker入门


下一篇:springboot集成freemarker静态资源无法访问