GSON on Google App Engine throws a Security Exception

后端 未结 4 624
忘掉有多难
忘掉有多难 2020-12-18 00:24

I am trying to convert an object into JSON using the GSON library on Google App Engine. For some reason, it throws this exception and I don\'t understand how to solve this.

4条回答
  •  执念已碎
    2020-12-18 01:11

    I experienced a similar problem recently.

    I was running Gson to parse JSON and it worked well for a long time so I didn't worry about GAE not allowing Reflection on it's platform.

    I introduced a HashMap the Form class and it worked well in my local system with Gson doing JSON Parse perfectly.

    But when I deployed that code to the Google App Engine Cloud it failed with the following exception:

    java.lang.SecurityException: java.lang.IllegalAccessException: Reflection is not allowed on private final int java.lang.ThreadLocal.threadLocalHashCode
    

    So now I've switched to Jackson JSON Parser which is faster and does not use reflection - but yes - more work.

提交回复
热议问题