這是我第一次谷歌應用程序引擎的servlet,我想讓它抓取的網站,所以我創建了應用程序引擎使用backgroundThread線程,我的問題是,當我運行在本地主機此應用程序:8888它可以正常工作並完成它應該完成的任務。500服務器錯誤,而部署谷歌應用程序
Youm7 youm7Crawler = new Youm7(); log.info("start 1"); Thread youm7Thread = ThreadManager.createBackgroundThread(youm7Crawler); log.info("start 2"); log.info("start 3"); youm7Thread.start();
但一旦我嘗試部署它作爲服務器,我得到一個錯誤500服務器,我在日誌中得到這個嚴重錯誤
`Uncaught exception from servlet
java.lang.IllegalStateException: This feature is only available to backend instances.
at com.google.appengine.api.system.SystemServiceImpl.translateException(SystemServiceImpl.java:40)
at com.google.appengine.api.system.SystemServiceImpl.startBackgroundRequest(SystemServiceImpl.java:28)
at com.google.apphosting.runtime.ApiProxyImpl$BackgroundThreadFactory.newThread(ApiProxyImpl.java:1125)
at com.google.appengine.api.ThreadManager.createBackgroundThread(ThreadManager.java:88)
at newscrawler.crawlerServlet.doGet(crawlerServlet.java:30)
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: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:57)
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:266)
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:438)
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 com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:722)
2013-04-29 06:27:25.205 /myreminderapp 200 66ms 0kb Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31`
所以我應該怎麼做,使它就像在服務器上在我的本地
[部署後的谷歌應用程序引擎運行錯誤的servlet(可能重複http://stackoverflow.com/questions/16252298/error-running-servlet-on-google-app-部署後的引擎) – 2013-04-29 18:21:41
兩天前你問了同樣的問題,並得到了答案,甚至接受了它。這個問題如何不同? – 2013-04-29 18:22:10
爲期2天的旅途中我使用不同類型的線程和不同的設計 現在從彼得服用意見後,我改變了這一切,它仍然無法正常工作,所以我發佈了一個不同的問題 – dab7 2013-04-29 20:19:43