views:

623

answers:

3

I would like to create a REST interface for my Java Google App Engine program. I figured I would start by generating some XML from my POJOS. However, it seems that XStream is bitten by GAE's restrictions.

What can I use to generate an XML string in Google App Engine?

Thanks.

Edit 1: Here is the beginning of the exception:

javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract    java.lang.String com.mydomain.client.ObjectService.sendObject(com.mydomain.client.models.myobject)' threw an unexpected exception: java.security.AccessControlException: access denied (java.io.SerializablePermission enableSubclassImplementation)
+1  A: 

For the same restriction (a patch is underway however) I ended producing JSON using org.json library. Also JAXB seems not to be in the whitelist.

dfa
+1  A: 

The exception is caused by a java.io.SerializablePermission, which according the javadoc is for allowing:

Subclass implementation of ObjectOutputStream or ObjectInputStream to override the default serialization or deserialization, respectively, of objects

XStream might be using Object streams under the covers, and falling foul of this permission not being granted.

Does Google App Engine actually have a whitelist, or just a set of restricted permissions? JAXB2 doesn't use Object streams, so have you actually tried that?

skaffman
Whitelist: http://code.google.com/appengine/docs/java/jrewhitelist.html
JP
+1  A: 

Try Jersey - it will give you XML, JSON, and lots more via REST; all using annotated methods.

It works for me, however there are some caveats:

See here and here

Damo
Do you use Jersey on Google App Engine?
JP