jackson-module-scala
jackson-module-scala copied to clipboard
AccessControlException is thrown on Google AppEngine while serializing object
There are some restrictions on Google AppEngine for using reflection.
com.fasterxml.jackson.module.scala.introspect.BeanIntrospector uses reflection to look up for constructor parameter names. Since v2.5.0 this operation is not wrapped into try/catch. Here is commit: https://github.com/FasterXML/jackson-module-scala/commit/5b36c6bdd87d5d3194c16ee089d3fc89a807bf1b#commitcomment-22367246
It causes an exception in runtime. Full stack trace is here: jackson-app-engine-stack-trace.txt
Now we use v2.4.5 and it works fine for us.
Is there a workaround other than registering a jackson module similar to DefaultScalaModule but without ScalaAnnotationIntrospectorModule? Something like this?
// avoid DefaultScalaModule (and ScalaAnnotationIntrospectorModule) per this bug:
// https://github.com/FasterXML/jackson-module-scala/issues/326
class AppengineScalaJacksonModule
extends JacksonModule
with IteratorModule
with EnumerationModule
with OptionModule
with SeqModule
with IterableModule
with TupleModule
with MapModule
with SetModule
// this one is private to package com.fasterxml.jackson.module.scala
// with ScalaNumberDeserializersModule
//
// this one fails on appengine with:
// java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
// https://github.com/FasterXML/jackson-module-scala/issues/326
// with ScalaAnnotationIntrospectorModule
with UntypedObjectDeserializerModule
with EitherModule {
override def getModuleName = "AppengineScalaJacksonModule"
}
What do we lose without ScalaAnnotationIntrospectorModule?
the issue is with our dependency on paranamer - I had removed the the paranamer dependency in jackson-module-scala v2.12.0 but had to bring it back due to https://github.com/FasterXML/jackson-module-scala/pull/510/files -- these are possibly edge cases - it might be possible to make the paranamer dependency optional again so that Google AppEngine users can use jackson-module-scala without paranamer
ScalaNumberDeserializersModule is now public (since v2.10.0, it seems)