Eclipse GWT和AppEngine - 不再执行本地任务队列

时间:2010-11-04 16:58:41

标签: google-app-engine gwt google-eclipse-plugin

在带有插件v1.4.0的Eclipse 3.6中,AppEngine 1.3.8 GWT 2.1.0本地任务队列不再被执行。

重现:

创建一个新的GWT和AppEngine项目(我称之为“test2”包 下文)

之前将以下内容添加到GreetingServiceImpl greetServer()方法中 回归线:

final Queue queue = QueueFactory.getDefaultQueue();
queue.add(TaskOptions.Builder.url("/taskrunner").param("id",
UUID.randomUUID().toString()));

使用以下命令在服务器包“TaskRunner”中创建一个类:

public class TaskRunner extends HttpServlet {

   @Override
   public void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
System.out.println("TaskRunner");
   }

   @Override
   public void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
System.out.println("TaskRunner");
   }

}

将以下内容添加到web.xml

<servlet>
 <servlet-name>taskRunner</servlet-name>
 <servlet-class>test2.server.TaskRunner</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>taskRunner</servlet-name>
  <url-pattern>/taskrunner</url-pattern>
</servlet-mapping>

运行项目并单击GWT按钮。大约10秒后你 将在控制台上获得以下异常:

[ERROR] Job default.task1 threw an unhandled Exception:
        com.google.apphosting.api.ApiProxy$ApplicationException:
        ApplicationError: 2: Received exception executing http method POST
        against URL http: //0.0.0.0:8888/taskrunner: No route to host: connect
               at
        com.google.appengine.api.urlfetch.dev.LocalURLFetchService.fetch(LocalURLFetchService.java:
        239)
               at com.google.appengine.api.labs.taskqueue.dev.LocalTaskQueue
        $UrlFetchServiceLocalTaskQueueCallback.execute(LocalTaskQueue.java:
        471)
               at
        com.google.appengine.api.labs.taskqueue.dev.UrlFetchJob.execute(UrlFetchJob.java:
        77)
               at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
               at org.quartz.simpl.SimpleThreadPool
        $WorkerThread.run(SimpleThreadPool.java:520)
        [ERROR] Job (default.task1 threw an exception.
        org.quartz.SchedulerException: Job threw an unhandled exception. [See
        nested exception: com.google.apphosting.api.ApiProxy
        $ApplicationException: ApplicationError: 2: Received exception
        executing http method POST against URL http: //0.0.0.0:8888/taskrunner:
        No route to host: connect]
               at org.quartz.core.JobRunShell.run(JobRunShell.java:214)
               at org.quartz.simpl.SimpleThreadPool
        $WorkerThread.run(SimpleThreadPool.java:520)
        * Nested Exception (Underlying Cause) ---------------
        com.google.apphosting.api.ApiProxy$ApplicationException:
        ApplicationError: 2: Received exception executing http method POST
        against URL http: //0.0.0.0:8888/taskrunner: No route to host: connect
               at
        com.google.appengine.api.urlfetch.dev.LocalURLFetchService.fetch(LocalURLFetchService.java:
        239)
               at com.google.appengine.api.labs.taskqueue.dev.LocalTaskQueue
        $UrlFetchServiceLocalTaskQueueCallback.execute(LocalTaskQueue.java:
        471)
               at
        com.google.appengine.api.labs.taskqueue.dev.UrlFetchJob.execute(UrlFetchJob.java:
        77)
               at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
               at org.quartz.simpl.SimpleThreadPool
        $WorkerThread.run(SimpleThreadPool.java:520)

从项目中移除GWT并且它可以正常工作!为了测试这个:

添加服务器类

 public class TaskRunnerTest extends HttpServlet {

 public void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {

  final Queue queue = QueueFactory.getDefaultQueue();
  queue.add(TaskOptions.Builder.url("/taskrunner").param("id", UUID.randomUUID().toString()));

}
  }

添加到web.xml

 <servlet>
   <servlet-name>taskRunnerTest</servlet-name>
  <servlet-class>test2.server.TaskRunnerTest</servlet-class>
 </servlet>
 <servlet-mapping>
   <servlet-name>taskRunnerTest</servlet-name>
   <url-pattern>/taskrunnertest</url-pattern>
   </servlet-mapping>

从项目中删除GWT(取消选中使用GWT)并点击http://127.0.0.1:8888/taskrunnertest - 不会抛出任何异常。 (启用GWT后,url会抛出异常)。

这曾用于启用GWT。请有人建议修复,因为它花了我2 到目前为止。

谢谢!

1 个答案:

答案 0 :(得分:0)

我得到了同样的错误,结果是因为我在USB 3G移动宽带棒上运行。它改变了笔记本电脑上的网络工作方式。

基本上http://0.0.0.0网址不再适用于我,localhost仍然这样做,这就是为什么我仍然可以浏览本地运行的应用程序 - 但是开发服务器上的任务队列似乎使用了0.0.0.0。