问题描述
我将我的应用程序托管在Google应用程序引擎上。我的应用程序应该做的每两分钟连接一个网站,解析它并使用C2DM将必要的信息发送到我的设备。我首先测试了我的应用程序,看看它是否能够正常工作它工作正常。但为了每两分钟检查一次webiste,我在while循环中放入必要的方法,然后将Thread.sleep(120000)放在while循环中。它有一段时间,但现在我得到这个:
从servlet未捕获的异常
com.google.apphosting.runtime.HardDeadlineExceededError:此请求(f6b9f0b8e1ec6f23)开始于2011年6月9日10:24:22.514 UTC,并且仍然在2011/06/09 10:24:52.824 UTC执行。
因此,在两分钟之前,每件事都可以。
,这是整个错误信息:
从servlet获取未捕获的异常
com .google.apphosting.runtime.HardDeadlineExceededError:此请求(f6b9f0b8e1ec6f23)于2011/06/09 10:24:22.514 UTC开始,并且仍在2011/06/09 10:24:52.824 UTC执行。
$ b $ java.util.AbstractStringBuilder.append(AbstractStringBuilder.java:408)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at java.lang.AbstractStringBuilder.append .StringBuilder。< init>(StringBuilder.java:110)
at tripplannerServer.ParseVerstoring.parsePlanned(ParseVerstoring.java:50)
at tripplannerServer.SendMessage2.geplandeVerstoring(SendMessage2.java:257)$ b $ tripplannerServer.TripplannerServerServlet.doGet(TripplannerServerServlet.java:152)$ b $ 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)
在com.goo gle.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)
在org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
在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。处理(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238)
at org.mortbay.jetty.handler.HandlerWrapper.handle( HandlerWrapper.java:152)
在org.mortbay.jett y.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)
,位于com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
位于com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:260)
在com.google.apphosting.base.RuntimePb $ EvaluationRuntime $ 2.handleRequest(RuntimePb.java:9669)
在com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:439 )
在com.google.net.rpc.impl.Server $ RpcTask.runInContext(Server.java:573)
在com.google.tracing.TraceContext $ TraceContextRunnable $ 1.run(TraceContext.java: 448)
,位于com.google.tracing.TraceContext.runInContext(TraceContex t.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)
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)$ b $在java.lang.Thread.run(Thread.java:636)
任何想法如何解决这个问题?或者使用Thread.sleep()的想法不好?如果没有,我应该如何让应用程序每隔两分钟检查一次网站?
预先感谢您。
任何前端应用程序都应在30秒内完成(HardDeadline)。基本上有2个选项,
- (更好的一种)改变你的应用逻辑,避免使用Thread.sleep()并使用cron.xml代替每x分钟启动一次你的应用。在你的情况下,always-on或taskQueue根本无济于事。
- 更改为,这样您就可以连续运行您的应用。
I host my application on google app engine. What my application should do is every two minutes connects to a website, parses it and send the necessary info to my device using C2DM. I first tested my application to see if it works once. And it works fine. But inorder to check the webiste every two minutes I put the necessary methods in a while loop and then put Thread.sleep(120000) in the while loop. It wokred for a while but now I get this:Uncaught exception from servletcom.google.apphosting.runtime.HardDeadlineExceededError: This request (f6b9f0b8e1ec6f23) started at 2011/06/09 10:24:22.514 UTC and was still executing at 2011/06/09 10:24:52.824 UTC.
So before the two minute thing every thing was ok.
and this is the whole error message:
Uncaught exception from servlet
com.google.apphosting.runtime.HardDeadlineExceededError: This request (f6b9f0b8e1ec6f23) started at 2011/06/09 10:24:22.514 UTC and was still executing at 2011/06/09 10:24:52.824 UTC.
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:408)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at java.lang.StringBuilder.<init>(StringBuilder.java:110)
at tripplannerServer.ParseVerstoring.parsePlanned(ParseVerstoring.java:50)
at tripplannerServer.SendMessage2.geplandeVerstoring(SendMessage2.java:257)
at tripplannerServer.TripplannerServerServlet.doGet(TripplannerServerServlet.java:152)
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: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:260)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9669)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:439)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:573)
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)
Any idea how to solve this? Or the idea to use Thread.sleep() is not good? If not how can I make the application check the website every two minutes?
Thank you in advance.
Any front-end app should be finished in 30 sec(HardDeadline). You have basically 2 options,
- (better one)change your app logic, avoid Thread.sleep() and use cron.xml instead to start your app every x minutes. In your case, always-on or taskQueue simply won't help.
- change to Backends so you can run your app continuously.
这篇关于谷歌应用程序引擎HardDeadlineExceededError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!