如何在Google App Engine上创建RESTful客户端?

时间:2012-09-04 19:54:42

标签: java json google-app-engine rest client

我正在尝试在Google App Engine(Java)上创建一个消耗Json的RESTful Web服务客户端。我已经尝试过Sitebricks和Jersey,但它们似乎都没有用。是否有可用于在GAE上创建RESTful Web服务客户端的框架?

Sitebricks的例外情况:

Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
    at java.security.AccessController.checkPermission(AccessController.java:555)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:283)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:308)
    at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
    at java.lang.Thread.init(Thread.java:376)
    at java.lang.Thread.<init>(Thread.java:525)
    at com.ning.http.client.AsyncHttpClientConfig$Builder$2.newThread(AsyncHttpClientConfig.java:421)
    at java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:598)
    at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:913)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1336)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:132)
    at com.ning.http.client.providers.jdk.JDKAsyncHttpProvider.execute(JDKAsyncHttpProvider.java:156)
    at com.ning.http.client.providers.jdk.JDKAsyncHttpProvider.execute(JDKAsyncHttpProvider.java:123)
    at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:496)
    at com.google.sitebricks.client.AHCWebClient.simpleRequest(AHCWebClient.java:85)
    at com.google.sitebricks.client.AHCWebClient.get(AHCWebClient.java:133)

泽西岛:

Caused by: java.security.AccessControlException: access denied ("javax.xml.bind.JAXBPermission" "setDatatypeConverter")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
    at java.security.AccessController.checkPermission(AccessController.java:555)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:283)
    at javax.xml.bind.DatatypeConverter.setDatatypeConverter(DatatypeConverter.java:134)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:304)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$3.run(JAXBContextImpl.java:303)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1170)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getStoredJAXBContext(AbstractJAXBProvider.java:194)
    at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getJAXBContext(AbstractJAXBProvider.java:187)
    at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getUnmarshaller(AbstractJAXBProvider.java:139)
    at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getUnmarshaller(AbstractJAXBProvider.java:122)
    at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:111)
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:565)
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:517)
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:684)
    at com.sun.jersey.api.client.WebResource.get(WebResource.java:191)

2 个答案:

答案 0 :(得分:1)

google-api-java-client怎么样?

在某种程度上,您需要的是能够发出HTTP请求并将响应解析为JSON。除了那些让Jersey / Sitebricks对你更具吸引力的东西之外你还有什么特色?

答案 1 :(得分:-1)

试试jello-framework。它允许您通过RESTful(OData)服务公开您的数据模型,并提供开箱即用的UI视图,以便您可以测试应用程序并立即开始与数据交互。

披露 - 我是Jello框架的创建者。不过,我决定将它作为RESTE客户端在GAE上的有效答案添加,因为它可以为问题提供一个很好的解决方案。