i am getting error while using objectify.
Actually i am using it in a very simple spring based application, but not getting the proper way to do the same.
to keep it simple, i am not using any service/dao layer.
Model:
package com.tut.yudi.model;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
//import java.util.Date;
import java.io.Serializable;
#Entity
public class Subject implements Serializable {
private static final long serialVersionUID = 1L;
//private long subjectId;
#Id
#Index
private String subjectName;
private int subjectRank;
private char status;
public String getSubjectName() {
return subjectName;
}
public void setSubjectName(String subjectName) {
this.subjectName = subjectName;
}
public int getSubjectRank() {
return subjectRank;
}
public void setSubjectRank(int subjectRank) {
this.subjectRank = subjectRank;
}
public char getStatus() {
return status;
}
public void setStatus(char status) {
this.status = status;
}
}
OfyService class:
package com.tut.yudi.common.dao;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;
import com.tut.yudi.model.Subject;
public class OfyService {
static {
factory().register(Subject.class);
//ObjectifyService.register(Subject.class); --also doesn't work
}
public static Objectify ofy() {
return ObjectifyService.ofy();
}
public static ObjectifyFactory factory() {
return ObjectifyService.factory();
}
}
my controller:
package com.tut.yudi.controller;
import static com.tut.yudi.common.dao.OfyService.ofy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.tut.yudi.controller.Hello;
import com.tut.yudi.model.Subject;
import java.util.logging.Logger;
#Controller
public class Hello
{
protected static Logger logger = Logger.getLogger(Hello.class.getName());
#RequestMapping("/")
public String home()
{
//sop();
return "a";
}
#RequestMapping(value = "/hello")
public String hello()
{
//sop();
//some comment
Subject subject = new Subject();
subject.setSubjectName("JAVA");
subject.setSubjectRank(1);
subject.setStatus('A');
System.out.println("Model object created...");
//some coment
ofy().save().entity(subject).now();
System.out.println("object created....");
return "b";
}
}
Here are the logs :
Dec 24, 2013 9:15:58 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed /var/vcap.local/dea/apps/app-g7u2pbf8emc4gvmc-0-df6c037b5f628879778de0427da1f7e4/app/WEB-INF/appengine-web.xml
Dec 24, 2013 9:15:58 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /var/vcap.local/dea/apps/app-g7u2pbf8emc4gvmc-0-df6c037b5f628879778de0427da1f7e4/app/WEB-INF/web.xml
Dec 24, 2013 9:15:58 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value '/var/vcap.local/dea/apps/app-g7u2pbf8emc4gvmc-0-df6c037b5f628879778de0427da1f7e4/appengine-java-sdk/config/sdk/logging.properties' with value 'WEB-INF/logging.properties' from '/var/vcap.local/dea/apps/app-g7u2pbf8emc4gvmc-0-df6c037b5f628879778de0427da1f7e4/app/WEB-INF/appengine-web.xml'
Dec 24, 2013 9:15:58 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Dec 24, 2013 9:15:59 PM com.google.appengine.tools.development.IsolatedAppClassLoader checkWorkingDirectory
WARNING: Your working directory, (/var/vcap.local/dea/apps/app-g7u2pbf8emc4gvmc-0-df6c037b5f628879778de0427da1f7e4) is not equal to your
web application root (/var/vcap.local/dea/apps/app-g7u2pbf8emc4gvmc-0-df6c037b5f628879778de0427da1f7e4/app)
You will not be able to access files from your working directory on the production server.
Dec 24, 2013 9:15:59 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
Dec 24, 2013 9:16:20 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
INFO: javax.servlet.ServletContext log: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Dec 24, 2013 9:16:27 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
INFO: javax.servlet.ServletContext log: Initializing Spring FrameworkServlet 'spring'
Dec 24, 2013 9:16:27 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started SelectChannelConnector#0.0.0.0:36886
Dec 24, 2013 9:16:27 PM com.google.appengine.tools.development.AbstractServer startup
INFO: Server default is running at http://localhost:36886/
Dec 24, 2013 9:16:27 PM com.google.appengine.tools.development.AbstractServer startup
INFO: The admin console is running at http://localhost:36886/_ah/admin
Dec 24, 2013 9:16:27 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: Dev App Server is now running
Dec 24, 2013 9:17:22 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /hello
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at com.tut.yudi.controller.Hello.hello(Hello.java:38)
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:616)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
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 com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectRequest(DevAppServerServersFilter.java:369)
at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectServerRequest(DevAppServerServersFilter.java:352)
at com.google.appengine.tools.development.DevAppServerServersFilter.doFilter(DevAppServerServersFilter.java:115)
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 com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:421)
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.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at com.googlecode.objectify.impl.TypeUtils.isAssignableFrom(TypeUtils.java:179)
at com.googlecode.objectify.impl.translate.NumberTranslatorFactory.create(NumberTranslatorFactory.java:25)
at com.googlecode.objectify.impl.translate.NumberTranslatorFactory.create(NumberTranslatorFactory.java:18)
at com.googlecode.objectify.impl.translate.TranslatorRegistry.create(TranslatorRegistry.java:90)
at com.googlecode.objectify.impl.translate.ClassTranslator.(ClassTranslator.java:52)
at com.googlecode.objectify.impl.translate.EntityClassTranslator.(EntityClassTranslator.java:46)
at com.googlecode.objectify.impl.Transmog.(Transmog.java:49)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.(ConcreteEntityMetadata.java:58)
at com.googlecode.objectify.impl.Registrar.register(Registrar.java:74)
at com.googlecode.objectify.ObjectifyFactory.register(ObjectifyFactory.java:180)
at com.tut.yudi.common.dao.OfyService.(OfyService.java:10)
... 58 more
Dec 24, 2013 9:17:22 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: Nested in java.lang.ExceptionInInitializerError:
java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at com.googlecode.objectify.impl.TypeUtils.isAssignableFrom(TypeUtils.java:179)
at com.googlecode.objectify.impl.translate.NumberTranslatorFactory.create(NumberTranslatorFactory.java:25)
at com.googlecode.objectify.impl.translate.NumberTranslatorFactory.create(NumberTranslatorFactory.java:18)
at com.googlecode.objectify.impl.translate.TranslatorRegistry.create(TranslatorRegistry.java:90)
at com.googlecode.objectify.impl.translate.ClassTranslator.(ClassTranslator.java:52)
at com.googlecode.objectify.impl.translate.EntityClassTranslator.(EntityClassTranslator.java:46)
at com.googlecode.objectify.impl.Transmog.(Transmog.java:49)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.(ConcreteEntityMetadata.java:58)
at com.googlecode.objectify.impl.Registrar.register(Registrar.java:74)
at com.googlecode.objectify.ObjectifyFactory.register(ObjectifyFactory.java:180)
at com.tut.yudi.common.dao.OfyService.(OfyService.java:10)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at com.tut.yudi.controller.Hello.hello(Hello.java:38)
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:616)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
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 com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectRequest(DevAppServerServersFilter.java:369)
at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectServerRequest(DevAppServerServersFilter.java:352)
at com.google.appengine.tools.development.DevAppServerServersFilter.doFilter(DevAppServerServersFilter.java:115)
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 com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:421)
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.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Thanks.
There are a couple of things that you should check:
The exception is related to Objectify's handling of primitive types in your Subject entity so I'd change to use Integer and Character (instead of char and int) in that class. I didn't manage to reproduce it so maybe it's a bug that was fixed or some other interaction.
Both #Id and #Index on Subject.subjectName seems not needed?
ETOOMUCHCOMPLEXITY: the layers of abstraction added by the frameworks cause the error information in the stack trace to not correlate with your source code. Build the tiniest new application that works. Gradually add and test pieces of your application until it breaks, then revert to what worked and try something else.
The earliest mention of your source code in the stack trace is Hello.java line 38. Counting them, line 38 is the end of file! It probably means the Hello class as a whole looks good but is failing to initialize. Since the Hello class itself is very simple, the fault is most likely in its relationship to other things it depends on.
Related
I working on a port of our Web application to GAE and Google Cloud SQL. I am using MySQL 5.6 and the DevAppServer locally during development, and I have some queries that take longer than 5 seconds to return. There seems to be some sort of default timeout and the query fails after approximately 5 seconds in the DevAppServer. I have not yet tried running this in GAE directly (mainly because I can't complete the page because the query keeps failing).
Here is the call stack:
Aug 08, 2016 10:34:05 AM org.glassfish.jersey.server.ServerRuntime$Responder mapException
FINER: Starting mapping of the exception.
org.glassfish.jersey.server.internal.process.MappableException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 5,006 milliseconds ago. The last packet sent successfully to the server was 5,001 milliseconds ago.
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.mapTargetToRuntimeEx(AbstractJavaResourceMethodDispatcher.java:179)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.access$200(AbstractJavaResourceMethodDispatcher.java:72)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:149)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:128)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:50)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
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 com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:511)
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.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 5,006 milliseconds ago. The last packet sent successfully to the server was 5,001 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:142)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:150)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3465)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3365)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3805)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1962)
at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:858)
at com.[redacted].[redacted].sql.SqlQuery.executeQuery(SqlQuery.java:132)
at com.[redacted].[redacted].business.user.InterfaceManager.performDQLSearch(InterfaceManager.java:216)
at com.[redacted].[redacted].business.user.InterfaceManager.performFilterSearch(InterfaceManager.java:275)
at com.[redacted].[redacted].rest.client.Search.searchFilter(Search.java:139)
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:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
... 55 more
Caused by: java.net.SocketException: Socket operation timed out: The API call remote_socket.Receive() took too long to respond and was cancelled.
at com.google.appengine.api.socket.SocketApiHelper.makeSyncCall(SocketApiHelper.java:76)
at com.google.appengine.api.socket.AppEngineSocketImpl.receive(AppEngineSocketImpl.java:710)
at com.google.appengine.api.socket.AppEngineSocketInputStream.read(AppEngineSocketInputStream.java:35)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:100)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:143)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:173)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2954)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3375)
... 74 more
Aug 08, 2016 10:34:05 AM com.[redacted].[redacted].rest.internal.GenericExceptionMapper toResponse
SEVERE: Communications link failure
The last packet successfully received from the server was 5,006 milliseconds ago. The last packet sent successfully to the server was 5,001 milliseconds ago.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 5,006 milliseconds ago. The last packet sent successfully to the server was 5,001 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:142)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:150)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3465)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3365)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3805)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1962)
at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:858)
at com.[redacted].[redacted].sql.SqlQuery.executeQuery(SqlQuery.java:132)
at com.[redacted].[redacted].business.user.InterfaceManager.performDQLSearch(InterfaceManager.java:216)
at com.[redacted].[redacted].business.user.InterfaceManager.performFilterSearch(InterfaceManager.java:275)
at com.[redacted].[redacted].rest.client.Search.searchFilter(Search.java:139)
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:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:128)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:50)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
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 com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:511)
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.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.net.SocketException: Socket operation timed out: The API call remote_socket.Receive() took too long to respond and was cancelled.
at com.google.appengine.api.socket.SocketApiHelper.makeSyncCall(SocketApiHelper.java:76)
at com.google.appengine.api.socket.AppEngineSocketImpl.receive(AppEngineSocketImpl.java:710)
at com.google.appengine.api.socket.AppEngineSocketInputStream.read(AppEngineSocketInputStream.java:35)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:100)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:143)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:173)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2954)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3375)
... 74 more
Aug 08, 2016 10:34:05 AM com.[redacted].[redacted].rest.internal.ResponseUtils addCommonHeaders
FINE: Set response header -> Access-Control-Allow-Origin: *
Aug 08, 2016 10:34:05 AM org.glassfish.jersey.server.ServerRuntime$Responder mapException
FINER: Exception 'Communications link failure
The last packet successfully received from the server was 5,006 milliseconds ago. The last packet sent successfully to the server was 5,001 milliseconds ago.' has been mapped by 'com.[redacted].[redacted].rest.internal.GenericExceptionMapper' to response 'Internal Server Error' (500:SERVER_ERROR).
It was able to put a break point in the MySQL driver code and found this exception:
java.net.SocketException: Socket operation timed out: The API call
remote_socket.Receive() took too long to respond and was cancelled.
Socket operation timed out: The API call remote_socket.Receive() took
too long to respond and was cancelled.
Now i have tried running the same SP call using my library code outside of the GAE DevAppServer and it works fine:
package com.[redacted].poc.sql.TestSQL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang3.time.StopWatch;
import com.[redacted].[redacted].data.DataTable;
import com.[redacted].[redacted].sql.AutoConnection;
import com.[redacted].[redacted].sql.DatabaseManager;
import com.[redacted].[redacted].sql.ResultSetEx;
import com.[redacted].[redacted].sql.SqlIntegerParameter;
import com.[redacted].[redacted].sql.SqlQuery;
import com.[redacted].[redacted].sql.SqlStringParameter;
/**
* Hello world!
*
*/
public class App {
private static final Logger logger = Logger.getLogger(App.class.getName());
public static void main(String[] args) {
try {
DatabaseManager.initialize("jdbc:mysql://127.0.0.1:3306/[redacted]?user=[redacted]&password=[redacted]");
final String xml = [redacted];
final StopWatch swTotal = new StopWatch();
final StopWatch swRs1 = new StopWatch();
final StopWatch swRs2 = new StopWatch();
try (AutoConnection db = new AutoConnection(DatabaseManager.getDbConnection())) {
assert (db != null);
assert (db.getConnection() != null);
try (final SqlQuery sql = DatabaseManager.buildStoredProcedureCall(logger, db.getConnection(),
"text_search", new SqlIntegerParameter("user_id", Integer.valueOf(2)),
new SqlIntegerParameter("project_id", Integer.valueOf(2)),
new SqlStringParameter("search_criteria_xml", xml), new SqlIntegerParameter("page_number", 1),
new SqlIntegerParameter("page_size", 25))) {
logger.info("Running query");
swTotal.start();
swRs1.start();
try (final ResultSetEx rs = new ResultSetEx(sql.executeQuery())) {
swRs1.stop();
final DataTable dt = DatabaseManager.copyToDataTable(rs);
logger.info(String.format("Returned %d rows", dt.getTotalRows()));
boolean pagingOk = false;
if (sql.getMoreResults()) {
swRs2.start();
try (final ResultSetEx rs2 = new ResultSetEx(sql.getResultSet())) {
swRs2.stop();
if (rs2.next()) {
pagingOk = true;
final int totalRows = rs2.getInt("total_rows");
final int lastPageNum = rs2.getInt("page_number");
final int lastPageSize = rs2.getInt("page_size");
final int totalPages = rs2.getInt("total_pages");
final String searchXml = rs2.getString("search_criteria_xml");
dt.setTotalRows(totalRows);
dt.setPageNumber(lastPageNum);
dt.setPageSize(lastPageSize);
dt.setTotalPages(totalPages);
dt.setSearchXml(searchXml);
}
}
}
if (!pagingOk) {
throw new Exception("Paging information results missing");
}
}
}
} finally {
logger.info("Total elapsed time : " + swTotal.toString());
logger.info("1st result set time :" + swRs1.toString());
logger.info("2nd result set time :" + swRs2.toString());
}
} catch (Exception ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
Here is the output:
Aug 08, 2016 10:42:46 AM com.[redacted].poc.sql.TestSQL.App main
INFO: Running query
Aug 08, 2016 10:42:55 AM com.[redacted].poc.sql.TestSQL.App main
INFO: Returned 25 rows
Aug 08, 2016 10:42:55 AM com.[redacted].poc.sql.TestSQL.App main
INFO: Total elapsed time : 00:00:08.900
Aug 08, 2016 10:42:55 AM com.[redacted].poc.sql.TestSQL.App main
INFO: 1st result set time :00:00:08.876
Aug 08, 2016 10:42:55 AM com.[redacted].poc.sql.TestSQL.App main
INFO: 2nd result set time :00:00:00.000
So it appears to me that something inside the GAE library is forcibly killing the SQL connection at the socket level. The application needs to process the query result, so I can't ignore it. Has anyone found a setting or some other way to resolve this issue? I've gone over the GAE docs at nausium, and done plenty of Google searching to no avail. It seems odd to me that there would be a hard 5 second limit on a query that you are unable to override. I know they allow a 60 second max timeout on UrlFetch and Task Queue calls, so I am hoping I am just missing something...
I submitted a bug to Google, and they verified it's an issue, so I guess it was not me. :)
https://code.google.com/p/googleappengine/issues/detail?id=13194
I have an application that connects to multiple databases within a single Google Cloud SQL instance. Based on a drop down selection, the GAE application will select records from one of 5 databases.
The problem is that when I select the first 4 databases (in no particular order in the drop down list), the GAE app connects successfully to the database and is able to retrieve records. But when I choose the fifth database from the drop down list, an error is thrown. The error and stack trace is as below. It is not an error with a specific database, as the error does not depend on the order of which database was selected. The last or fifth database chosen, immaterial of which, always fails with the same error message.
Any advise will be very much appreciated.
InspectAPI.java:
public Element[] getComponentsList(#Named("province")String provinceName, User user) throws Exception {
if (user == null) {
throw new UnauthorizedException("API calls must be authenticated.");
}
if (!AuthorizationService.hasAnyOrRoles(user.getEmail(), AuthorizationService.ROLE_ALL_ROLES)
|| !AuthorizationService.hasProvincieAccess(user.getEmail(), provinceName)) {
throw new UnauthorizedException("You are not authorized to invoke this API method.");
}
EntityManager em = null;
Element[] e = null;
try {
em = EMF.getFStore().createEntityManager();
em.getTransaction().begin();
e = (ElementRubrieken[]) em.createQuery("SELECT i FROM Element i").getResultList()
.toArray(new Element[0]);
} catch (NoResultException nre) {
// no result
if (e == null) {
return e;
}
} catch (Exception ex) {
log.log(Level.SEVERE, "Unable to get inspections.", ex);
throw new InternalServerErrorException("Unable to get inspections.");
} finally {
if (em != null) {
em.getTransaction().commit();
em.close();
}
}
return e;
}
EMF.java
public static EntityManagerFactory getFicheStore() {
if (emfFicheInstance == null) {
Map<String, String> properties = new HashMap<String, String>();
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
properties.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.GoogleDriver");
properties.put("javax.persistence.jdbc.url", System.getProperty("cloudsql.prod.f.url"));
properties.put("javax.persistence.jdbc.user", System.getProperty("cloudsql.prod.f.user"));
properties.put("javax.persistence.jdbc.password", System.getProperty("cloudsql.prod.f.password"));
properties.put("javax.persistence.jdbc.db", System.getProperty("cloudsql.prod.f.db"));
} else {
properties.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
properties.put("javax.persistence.jdbc.url", System.getProperty("cloudsql.dev.f.url"));
properties.put("javax.persistence.jdbc.user", System.getProperty("cloudsql.dev.f.user"));
properties.put("javax.persistence.jdbc.password", System.getProperty("cloudsql.dev.f.password"));
properties.put("javax.persistence.jdbc.db", System.getProperty("cloudsql.dev.f.db"));
}
emfFicheInstance = Persistence.createEntityManagerFactory(
System.getProperty("com.myproject.services.emfFactory.persistenceUnitName"),
properties);
}
return emfFicheInstance;
}
Error and stack trace:
E 00:42:39.184 com.myproject.api.InspectAPI getComponentsList: Unable to get inspections.
javax.persistence.PersistenceException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:270)
at org.datanucleus.api.jpa.JPAQuery.getResultList(JPAQuery.java:202)
at com.myproject.api.InspectAPI.getComponentsList(InspectAPI.java:223)
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:606)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_$1.run(Method_.java:179)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.privilegedInvoke(Method_.java:176)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke_(Method_.java:137)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke(Method_.java:45)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
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 com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
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 com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:254)
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 com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:484)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:438)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:445)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:442)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:724)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:46)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:350)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2416)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2450)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2235)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:818)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:46)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
at com.mysql.jdbc.GoogleNonRegisteringDriver$JdbcWrapper.getInstance(GoogleNonRegisteringDriver.java:276)
at com.mysql.jdbc.GoogleNonRegisteringDriver.connect(GoogleNonRegisteringDriver.java:246)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:187)
at org.datanucleus.store.rdbms.datasource.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:78)
at org.datanucleus.store.rdbms.datasource.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.datanucleus.store.rdbms.datasource.dbcp.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1158)
at org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:108)
at org.datanucleus.store.rdbms.ConnectionProviderPriorityList.getConnection(ConnectionProviderPriorityList.java:57)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl.getConnection(ConnectionFactoryImpl.java:354)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl.getXAResource(ConnectionFactoryImpl.java:314)
at org.datanucleus.store.connection.ConnectionManagerImpl.enlistResource(ConnectionManagerImpl.java:354)
at org.datanucleus.store.connection.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:226)
at org.datanucleus.store.connection.AbstractConnectionFactory.getConnection(AbstractConnectionFactory.java:60)
at org.datanucleus.store.AbstractStoreManager.getConnection(AbstractStoreManager.java:432)
at org.datanucleus.store.AbstractStoreManager.getConnection(AbstractStoreManager.java:401)
at org.datanucleus.store.rdbms.query.JPQLQuery.performExecute(JPQLQuery.java:512)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1789)
at org.datanucleus.store.query.Query.executeWithMap(Query.java:1693)
at org.datanucleus.api.jpa.JPAQuery.getResultList(JPAQuery.java:185)
<continued in next message>
E 00:42:39.184 <continued from previous message>
at com.myproject.api.InspectAPI.getComponentsList(InspectAPI.java:223)
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:45)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
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:438)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:445)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:442)
... 1 more
Caused by: java.net.SocketException: Unable to open connection to the instance: myproject-tst:mysql
at com.mysql.jdbc.GoogleCloudSqlSocket.<init>(GoogleCloudSqlSocket.java:48)
at com.mysql.jdbc.GoogleCloudSqlSocketFactory.connect(GoogleCloudSqlSocketFactory.java:81)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
... 64 more
Caused by: java.io.FileNotFoundException: /cloudsql/myproject-tst:mysql (No such file or directory)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:132)
at com.mysql.jdbc.GoogleCloudSqlSocket$RandomAccessFileHelper.getFile(GoogleCloudSqlSocket.java:249)
at com.mysql.jdbc.GoogleCloudSqlSocket.<init>(GoogleCloudSqlSocket.java:46)
... 66 more
I see two posibble reason for this error:
You are hitting the limit of 12 concurrent connections described here [1]. For some reason you might be not closing connections properly.
I'm not an expert on JPA but i think You need to stablish a single persistence unit per database yo want to connect to [2].
[1] https://cloud.google.com/appengine/docs/java/cloud-sql/#Java_Managing_connections
[2] http://www.mastertheboss.com/jboss-frameworks/hibernate-jpa/jpa-configuration/how-to-use-multiple-database-in-persistencexml
It was a old project on GAE one year ago. It works pretty well at that time. Recently I tried to work on this project again, but it doesn't work well now. I figured out what the problem is, but I don't know how to solve it.
Add new user is ok. but when I trying to add image of a user, the image file itself stored in blobstore succesfully but the record entity Imagecould not be persist.
It seems that gae couldn't set the value of the image field in User table and come up with a strange error which says String too long. It probably related to LAZY loading stuff.
I would be appercaite if you could help me out.
Here is my entities and the code where the error happen.
OnetoMany relationship in User entity:
#Entity
public class User {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
#GeneratedValue(strategy = GenerationType.SEQUENCE)
Integer userid;
String username;
String password;
String email;
#OneToMany()
Collection<Image> images;
// getter and setter....
}
Image Entity:
#Entity
public class Image {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
#GeneratedValue(strategy = GenerationType.SEQUENCE)
Integer imageid;
private String name;
// full path of blobstore
private String path;
private Date uploadtime;
}
Where the error occur:
//ImageService.java/uploadImage
user = userDao.findUser(userid);
Collection<Image> images = user.getImages();
images.add(image); // Exception occurs here
user.setImages(images);
userDao.update(user);
Stack Trace:
com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java.lang.IllegalArgumentException: path: String properties must be 500 characters or less. Instead, use com.google.appengine.api.datastore.Text, which can store strings of any length.
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:242)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:207)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:173)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:148)
at com.google.appengine.api.datastore.PropertyContainer.setProperty(PropertyContainer.java:101)
at com.google.appengine.datanucleus.EntityUtils.setEntityProperty(EntityUtils.java:169)
at com.google.appengine.datanucleus.StoreFieldManager.storeFieldInEntity(StoreFieldManager.java:245)
at com.google.appengine.datanucleus.StoreFieldManager.storeStringField(StoreFieldManager.java:168)
at org.datanucleus.state.AbstractStateManager.providedStringField(AbstractStateManager.java:1438)
at com.nhm.persistence.entity.Image.jdoProvideField(Image.java)
at com.nhm.persistence.entity.Image.jdoProvideFields(Image.java)
at org.datanucleus.state.AbstractStateManager.provideFields(AbstractStateManager.java:1520)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.insertObjectsInternal(DatastorePersistenceHandler.java:232)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:214)
at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2371)
at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2347)
at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1798)
at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1892)
at org.datanucleus.store.types.sco.SCOUtils.validateObjectForWriting(SCOUtils.java:1501)
at com.google.appengine.datanucleus.scostore.AbstractFKStore.validateElementForWriting(AbstractFKStore.java:383)
at com.google.appengine.datanucleus.scostore.FKListStore.validateElementForWriting(FKListStore.java:1029)
at com.google.appengine.datanucleus.scostore.FKListStore.internalAdd(FKListStore.java:193)
at com.google.appengine.datanucleus.scostore.FKListStore.addAll(FKListStore.java:114)
at org.datanucleus.store.types.sco.backed.ArrayList.addAll(ArrayList.java:727)
at org.datanucleus.store.types.sco.backed.ArrayList.initialise(ArrayList.java:161)
at org.datanucleus.store.types.sco.SCOUtils.createSCOWrapper(SCOUtils.java:249)
at org.datanucleus.store.types.sco.SCOUtils.newSCOInstance(SCOUtils.java:140)
at org.datanucleus.state.JDOStateManager.wrapSCOField(JDOStateManager.java:2225)
at org.datanucleus.state.AbstractStateManager.setObjectField(AbstractStateManager.java:2051)
at com.nhm.persistence.entity.User.jdoSetimages(User.java)
at com.nhm.persistence.entity.User.setImages(User.java:131)
at com.nhm.web.service.ImageService.uploadImage(ImageService.java:96)
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:43)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
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:480)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:487)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:774)
at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:751)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:484)
at java.lang.Thread.run(Thread.java:679)
Thank you!
If you want to store Strings longer than 500 Unicode characters you need to use Text instead. See Datastore Properties & Value Types.
What I have done is a movie website. It will show the latest movie info and showtimes.
I have a cron job to update all the playing movies. However, whenever it runs, it throws a ApiProxy$CancelledException and have a terrible cpu-time about 4706364 cpu_ms 4644739 api_cpu_ms that make my APP exceeds quota very soon. Could someone help me. Thanks!!
The number of the playing movies is around 25, and the number of the showtimes is around 650.
My code
// Get all the playing movies from the datasotre
Query query = pm.newQuery(Movie.class);
query.setFilter("playing == true");
List<Movie> playingMovies = (List<Movie>) query.execute();
// Update every playing movie
for (Movie m : playingMovies) {
// getMovie() will return a movie with latest movie info and showtimes
Movie leMovie = getMovie(m.getId());
leMovie.setKey(m.getKey());
leMovie.setFans(m.getFans());
// because leMovie has the latest showtimes so I need to delete the older showtimes
m.getShowtimeList().clear();
pm.makePersistent(leMovie);
}
My Movie Class
#PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Movie {
#Persistent
private Set<Key> fans;
#PrimaryKey
#Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
#Persistent
private String id;
#Persistent
private boolean playing;
#Persistent
private int gate;
#Persistent
private String picUrl;
#Persistent
private String mainName;
#Persistent(mappedBy = "movie")
#Element(dependent = "true")
private List<Showtime> showtimeList;
//......
The Exception
2011-08-22 10:30:00.138
/cron/update-movie
com.google.apphosting.api.ApiProxy$CancelledException: The API call datastore_v3.Put() was explicitly cancelled.
at com.google.apphosting.runtime.ApiProxyImpl$5.get(ApiProxyImpl.java:298)
at com.google.apphosting.runtime.ApiProxyImpl$5.get(ApiProxyImpl.java:296)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:67)
at com.google.appengine.api.datastore.FutureHelper$CumulativeAggregateFuture.get(FutureHelper.java:144)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:72)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:33)
at com.google.appengine.api.datastore.DatastoreServiceImpl$2.runInternal(DatastoreServiceImpl.java:113)
at com.google.appengine.api.datastore.DatastoreServiceImpl$2.runInternal(DatastoreServiceImpl.java:110)
at com.google.appengine.api.datastore.TransactionRunner.runInTransaction(TransactionRunner.java:31)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put(DatastoreServiceImpl.java:110)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put(DatastoreServiceImpl.java:94)
at org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.put(RuntimeExceptionWrappingDatastoreService.java:94)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:180)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:139)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:134)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.updateObject(DatastorePersistenceHandler.java:536)
at org.datanucleus.state.JDOStateManagerImpl.flush(JDOStateManagerImpl.java:4576)
at org.datanucleus.ObjectManagerImpl.flushInternal(ObjectManagerImpl.java:2814)
at org.datanucleus.ObjectManagerImpl.flush(ObjectManagerImpl.java:2754)
at org.datanucleus.ObjectManagerImpl.preCommit(ObjectManagerImpl.java:2893)
at org.datanucleus.TransactionImpl.internalPreCommit(TransactionImpl.java:369)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:256)
at org.datanucleus.ObjectManagerImpl.close(ObjectManagerImpl.java:801)
at org.datanucleus.jdo.JDOPersistenceManager.close(JDOPersistenceManager.java:271)
at com.mm.servlet.UpdateMovieServlet.doGet(UpdateMovieServlet.java:100)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
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 com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
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 com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
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 com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:262)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9819)
at com.google.net.rpc.impl.RpcUtil.handleRequest(RpcUtil.java:445)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:414)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:579)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:454)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:694)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:332)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:324)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:452)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
C 2011-08-22 10:30:00.144
Uncaught exception from servlet
com.google.apphosting.api.ApiProxy$CancelledException: The API call datastore_v3.Put() was explicitly cancelled.
at com.google.apphosting.runtime.ApiProxyImpl$5.get(ApiProxyImpl.java:298)
at com.google.apphosting.runtime.ApiProxyImpl$5.get(ApiProxyImpl.java:296)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:67)
at com.google.appengine.api.datastore.FutureHelper$CumulativeAggregateFuture.get(FutureHelper.java:144)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:72)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:33)
at com.google.appengine.api.datastore.DatastoreServiceImpl$2.runInternal(DatastoreServiceImpl.java:113)
at com.google.appengine.api.datastore.DatastoreServiceImpl$2.runInternal(DatastoreServiceImpl.java:110)
at com.google.appengine.api.datastore.TransactionRunner.runInTransaction(TransactionRunner.java:31)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put(DatastoreServiceImpl.java:110)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put(DatastoreServiceImpl.java:94)
at org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.put(RuntimeExceptionWrappingDatastoreService.java:94)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:180)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:139)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.put(DatastorePersistenceHandler.java:134)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.updateObject(DatastorePersistenceHandler.java:536)
at org.datanucleus.state.JDOStateManagerImpl.flush(JDOStateManagerImpl.java:4576)
at org.datanucleus.ObjectManagerImpl.flushInternal(ObjectManagerImpl.java:2814)
at org.datanucleus.ObjectManagerImpl.flush(ObjectManagerImpl.java:2754)
at org.datanucleus.ObjectManagerImpl.preCommit(ObjectManagerImpl.java:2893)
at org.datanucleus.TransactionImpl.internalPreCommit(TransactionImpl.java:369)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:256)
at org.datanucleus.ObjectManagerImpl.close(ObjectManagerImpl.java:801)
at org.datanucleus.jdo.JDOPersistenceManager.close(JDOPersistenceManager.java:271)
at com.mm.servlet.UpdateMovieServlet.doGet(UpdateMovieServlet.java:100)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
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 com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
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 com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
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 com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:262)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9819)
at com.google.net.rpc.impl.RpcUtil.handleRequest(RpcUtil.java:445)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:414)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:579)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:454)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:694)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:332)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:324)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:452)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
W 2011-08-22 10:30:00.451
A serious problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may be throwing exceptions during the initialization of your application. (Error code 104)
Maybe it is too late to reply...
Usual request time is about one minute, if "getMovie(m.getId());" request info from some other server it may take long and go through your minute.
GAE task has more time to run jobs so better you use your cron to enqueue a new task and let appengine do your work in the background.
Task t = new Task();
t.setUrl(URL_SERVLET_TO_UPDATE_MOVIES);
//submit task
TaskReference tr = queue.add(t);
This servlet runs the job of updating movies.
Even needing more time (lets assume you got plenty of movies there) you can get only a few number of movies per query, actualize them, get a Cursor (works as range) and enqueue a new task with that cursor as parameter to the servlet.
This new task will start from the next movie you have to actualize (thanks to the Cursor) and you will have full time to do your job. You can chain task until your job is done.
At your servlet look for a cursor as param:
String encodedCursor = req.getParameter(CURSOR_PARAM);
if ( encodedCursor != null){
oldCursor = Cursor.fromWebSafeString(encodedCursor);
}
You can use this Cursor to query from the last movie you queried.
Get a new cursor from the new query and add it as parameter to the new task.
Task t = new Task();
t.setUrl(PROCESSOR_SERVLET);
//add cursor as parameter
t.addParameter(CURSOR_PARAM, cursor.toWebSafeString());
//submit task
TaskReference tr = queue.add(t);
Using Task and cursors you will get your job done in the background avoiding time limits.
Of course, there are quotas over there...
Doc about cursors:
https://developers.google.com/appengine/docs/java/datastore/queries#Query_Cursors
My app has been purring along for a month with only the occasional deadline exceeded exception. This morning, in a space of five minutes, I had 150 deadline exceeded exceptions. Now it's back to normal. I understand that this can just happen, and isn't necessarily going to be resolved by anything that I do in my code, but every single exception has appstats in the stack trace (at least the 20 I looked at most carefully). On one hand, this implicates appstats - on the other hand, I guess appstats is probably in every single stack trace that ever runs. I'm trying to determine if appstats was the problem.
I'm not an expert with filters - can anyone tell me if a stack trace like the one below implies that the code was waiting in appstats for a long time? It seems like it does mean that, but I thought maybe filters are chained together in such a way that confuses the stack trace. Also, even if it was waiting in appstats - it seems like the problem might be datastore unavailability (no problems evident on the global appengine status page).
I put asterisks at the beginning of the obvious appstats calls for quick scanning.
javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.activegrade.shared.dto.ResultDTO com.activegrade.client.serviceinterfaces.CourseOperationService.getCourseList(com.activegrade.shared.dto.AuthInfo)' threw an unexpected exception: com.google.apphosting.api.DeadlineExceededException: This request (1ff876185c635baf) started at 2010/11/30 14:35:47.278 UTC and was still executing at 2010/11/30 14:36:16.261 UTC.
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:207)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
**at com.google.appengine.tools.appstats.AppstatsFilter.doFilter(AppstatsFilter.java:140)**
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
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 com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238)
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 com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:261)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:8486)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:8484)
at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:418)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:572)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: com.google.apphosting.api.DeadlineExceededException: This request (1ff876185c635baf) started at 2010/11/30 14:35:47.278 UTC and was still executing at 2010/11/30 14:36:16.261 UTC.
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:502)
**at com.google.appengine.tools.appstats.RecordingFuture.get(RecordingFuture.java:99)
**at com.google.appengine.tools.appstats.RecordingFuture$ExtendedFuture.get(RecordingFuture.java:44)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:42)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:42)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:71)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:32)
at com.google.appengine.api.datastore.QueryResultsSourceImpl.loadMoreEntities(QueryResultsSourceImpl.java:69)
at com.google.appengine.api.datastore.QueryResultsSourceImpl.loadMoreEntities(QueryResultsSourceImpl.java:56)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.ensureLoaded(QueryResultIteratorImpl.java:156)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.hasNext(QueryResultIteratorImpl.java:65)
at org.datanucleus.store.appengine.DatastoreElementContainerStoreSpecialization.getChildren(DatastoreElementContainerStoreSpecialization.java:105)
at org.datanucleus.store.appengine.DatastoreFKListStore.listIterator(DatastoreFKListStore.java:48)
at org.datanucleus.store.mapped.scostore.AbstractListStore.listIterator(AbstractListStore.java:84)
at org.datanucleus.store.mapped.scostore.AbstractListStore.iterator(AbstractListStore.java:74)
at org.datanucleus.sco.backed.List.loadFromStore(List.java:241)
at org.datanucleus.sco.backed.List.initialise(List.java:190)
at org.datanucleus.sco.SCOUtils.newSCOInstance(SCOUtils.java:183)
at org.datanucleus.store.mapped.mapping.AbstractContainerMapping.replaceFieldWithWrapper(AbstractContainerMapping.java:426)
at org.datanucleus.store.mapped.mapping.AbstractContainerMapping.postFetch(AbstractContainerMapping.java:444)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.runPostFetchMappingCallbacks(DatastorePersistenceHandler.java:510)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:489)
at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo(DatastoreQuery.java:565)
at org.datanucleus.store.appengine.DatastoreRelationFieldManager.lookupOneToOneChild(DatastoreRelationFieldManager.java:320)
at org.datanucleus.store.appengine.DatastoreRelationFieldManager.fetchRelationField(DatastoreRelationFieldManager.java:274)
at org.datanucleus.store.appengine.DatastoreFieldManager.fetchObjectField(DatastoreFieldManager.java:289)
at org.datanucleus.state.AbstractStateManager.replacingObjectField(AbstractStateManager.java:1197)
at com.activegrade.server.dao.Course.jdoReplaceField(Course.java)
at com.activegrade.server.dao.Course.jdoReplaceFields(Course.java)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2772)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2791)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:480)
at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo(DatastoreQuery.java:565)
at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo(DatastoreQuery.java:520)
at org.datanucleus.store.appengine.query.DatastoreQuery.access$300(DatastoreQuery.java:110)
at org.datanucleus.store.appengine.query.DatastoreQuery$6.apply(DatastoreQuery.java:638)
at org.datanucleus.store.appengine.query.DatastoreQuery$6.apply(DatastoreQuery.java:630)
at org.datanucleus.store.appengine.query.LazyResult.resolveNext(LazyResul
Appstats inserts instrumentation into the App Engine stack, in order to time all the RPC calls your app makes. Since DeadlineExceeded errors are thrown by the RPC, Appstats will always be in the stack. The call in question wasn't made by appstats - it was simply recording it.