AbstractRequestContext.doFire中的NullPointerException(AbstractRequestContext.java:1102)

bem*_*bii 2 java gwt google-app-engine

我刚刚开始使用Google AppEngine进行开发,现在我遇到了第一个问题.

我从Google-IO 2011中获取了Todo-Example-Project并进行了一些更改,现在我在我的应用程序中获得了以下StackTrace:

Caused by: java.lang.NullPointerException: null
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.doFire(AbstractRequestContext.java:1102)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.fire(AbstractRequestContext.java:569)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequest.fire(AbstractRequest.java:54)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequest.fire(AbstractRequest.java:59)
Run Code Online (Sandbox Code Playgroud)

我尝试使用此代码在GWT-Client中创建一个新实体:

MyRequest request = requestFactory.myRequest();
request.createTime().fire();
Run Code Online (Sandbox Code Playgroud)

服务级别的代码

static DataStore db = new DataStore();

public static Time createTime() {
    return db.update(new Time());
}
Run Code Online (Sandbox Code Playgroud)

这是数据存储级中的代码

public Time update(Time item) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try {
        pm.makePersistent(item);
        return item;
    } finally {
        pm.close();
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望你能帮我解决这个问题.

谢谢

编辑:我想我应该补充一下,当然我已经实现了一个TimeLocator-Class和一个ServiceLocator-Class.

这是我的web.xml,因为我认为可能存在问题:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemalocation="http://java.sun.com/xml/ns/javaee
                        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>Test.html</welcome-file>
  </welcome-file-list>

  <!-- RequestFactory Servlet -->

  <servlet>
    <servlet-name>requestFactoryServlet</servlet-name>
    <servlet-class>com.google.web.bindery.requestfactory.server.RequestFactoryServlet</servlet-class>
    <init-param>
      <param-name>symbolMapsDirectory</param-name>
      <!-- You'll need to compile with -extras and move the symbolMaps directory
           to this location if you want stack trace deobfuscation to work -->
      <param-value>WEB-INF/classes/symbolMaps/</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>requestFactoryServlet</servlet-name>
    <url-pattern>/gwtRequest</url-pattern>
  </servlet-mapping>

  <!-- Other servlets -->

  <servlet>
    <servlet-name>dataMessagingServlet</servlet-name>
    <servlet-class>
      com.google.android.c2dm.server.C2DMRetryServlet
    </servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>dataMessagingServlet</servlet-name>
      <url-pattern>/tasks/c2dm</url-pattern>
  </servlet-mapping>

  <!-- Security -->

  <!--  Require user login for the .html welcome page -->
  <security-constraint>
    <web-resource-collection>
      <url-pattern>/Test.html</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>*</role-name>
    </auth-constraint>
  </security-constraint>

  <!--  Require admin role for the tasks servlet -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>tasks</web-resource-name>
      <url-pattern>/tasks/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>admin</role-name>
    </auth-constraint>
  </security-constraint>

</web-app>
Run Code Online (Sandbox Code Playgroud)

Tho*_*yer 5

你是否正确初始化RequestFactory实例?

看起来你没有初始化RequestTransport:AbstractRequestContext.java:1102