我以这种方式修改了 Eclipse 生成的默认谷歌云端点:
@ApiMethod(name = "insertDeviceInfo")
public DeviceInfo insertDeviceInfo(DeviceInfo deviceinfo) {
EntityManager mgr = getEntityManager();
try {
if (containsDeviceInfo(deviceinfo)) {
logger.info("deviceinfo: già presente (insertDeviceinfo)");
throw new EntityExistsException("Object already exists");
logger.info("deviceinfo: già presente (insertDeviceinfo)");
}
mgr.persist(deviceinfo);
String iddevice= deviceinfo.getDeviceRegistrationID();
logger.info("deviceinfo: "+iddevice+" , "+deviceinfo.getDeviceInformation()+" , "+deviceinfo.getLanguage()+" , "+deviceinfo.getTimestamp()+ " , "+deviceinfo.getTimestamplastused());
ChannelJDOWrapper.idDevice.add(iddevice);
CacheSupport.cachePut(DeviceInfo.class.getName(), deviceinfo.getDeviceRegistrationID(), deviceinfo);
logger.info("dispositivo inserito");
} finally {
mgr.close();
}
ChannelJDOWrapper.idDevice 是一个静态的 LinkedList<String>()。
现在有时我会收到此异常:
com.google.api.server.spi.SystemService invokeServiceMethod: This operation is not supported on Query Results
java.lang.UnsupportedOperationException: This operation is not supported on Query Results
at org.datanucleus.query.evaluator.InMemoryQueryResult.add(InMemoryQueryResult.java:321)
at com.iuculano.tvitaliane.server.DeviceInfoEndpoint.insertDeviceInfo(DeviceInfoEndpoint.java:163)
at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:361)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:124)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:82)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:435)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:442)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:186)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:306)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:298)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:439)
at java.lang.Thread.run(Thread.java:722)
DeviceInfoEndpoint.java:163 是:
ChannelJDOWrapper.idDevice.add(iddevice);
为什么?