Hi Abe,

I came across the same problem as you, and I don't think there's any
workaround other than using JSON or converting your JS objects to
'pure' Java objects such as java.util.HashMaps etc.

Considering the complexity of Java serialization, I think JSON is
actually quite compelling, but of course it depends on your project's
requirements.

Hannes

On Sep 1, 7:34 am, Abe Parvand <[email protected]> wrote:
> Hey all,
>
> I tried posting this on the appengine group a while back, but no
> success.
>
> For reference, it's here: (http://groups.google.com/group/google-
> appengine-java/browse_thread/thread/2124e4ffdbe79ff7/ca50fbb0408ba87f?
> lnk=gst&q=java.io.SerializablePermission#ca50fbb0408ba87f)
>
> Long story short, doing the following breaks in appengine:
>
>                         Scriptable obj = ...
>
>                         ByteArrayOutputStream bs = new
> ByteArrayOutputStream();
>                         ScriptableOutputStream out = new
> ScriptableOutputStream(bs, scope); // breaks here!
>                         out.writeObject(obj);
>
>                         Blob blobToSave = new Blob(bs.toByteArray());
>                         // do something with blob
>
>                         bs.close();
>                         out.close();
>
> The reason is because in appengine, there is a missing security
> permission that the Rhino Serializer is trying to use:
>
> Uncaught exception from servlet
> java.security.AccessControlException: access denied
> (java.io.SerializablePermission enableSubstitution)
>         at java.security.AccessControlContext.checkPermission(Unknown
> Source)
>         at java.security.AccessController.checkPermission(Unknown
> Source)
>         at java.lang.SecurityManager.checkPermission(Unknown Source)
>         at java.io.ObjectOutputStream.enableReplaceObject(Unknown
> Source)
>         at
> org.mozilla.javascript.serialize.ScriptableOutputStream.<init>
> (ScriptableOutputStream.java:84)
>
> Does anyone know how I can use the serializer in appengine? I have
> implemented a utility class that converts between Scriptable and JSON
> string representation, but it is admittedly not as robust as the
> serializer and I really don't want to reinvent the wheel here. I
> greatly appreciate your help!

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to