IllegalAccessError when initializing Freemarker using Google App Engine

I am trying to use Freemarker 2.3 with GAE 1.7.1 (I also do some tests with 1.8.1.1), but I have a very strange error that occurs when initializing 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) 

This happens when an instance of the Configuration object is created:

 Configuration configuration = new Configuration(); 

I tried changing the main logger by calling Logger.selectLoggerLibrary, but I have something like this ...

Many thanks for your help.

+4
source share
1 answer

Try selecting LIBRARY_SLF4J or LIBRARY_COMMONS using Logger.selectLoggerLibrary . Does the problem go away?

Update: I see why it does this for Log4J on GAE. It will be fixed in 2.3.20-gae.

+3
source

Source: https://habr.com/ru/post/1488360/


All Articles