带数据存储的Google端点:java.lang.ExceptionInInitializerError

时间:2016-11-22 09:14:45

标签: google-app-engine google-cloud-datastore google-cloud-endpoints

我坚持使用数据存储。

我正在尝试使用数据存储运行Google端点。

mvn appengine:update命令之后,我可以在资源管理器上看到我的方法,但它没有得到执行,因为它有错误。

这是错误:

java.lang.ExceptionInInitializerError

这是我正在尝试执行的功能:

@ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) public Profile saveProfile(final User user, ProfileForm profileForm) throws UnauthorizedException { TeeShirtSize teeShirtSize = TeeShirtSize.NOT_SPECIFIED; if (user == null) { throw new UnauthorizedException("Authorization required"); } String userId = user.getUserId(); String mainEmail = user.getEmail(); String displayName = profileForm.getDisplayName(); if (profileForm.getTeeShirtSize() != null) { teeShirtSize = profileForm.getTeeShirtSize(); } if (displayName == null) { displayName = extractDefaultDisplayNameFromEmail(user.getEmail()); } Profile profile = new Profile(userId, displayName, mainEmail, teeShirtSize);ofy().save().entity(profile).now(); return profile; }

1 个答案:

答案 0 :(得分:0)

你忘了注册Objectify。创建一个像

这样的启动servlet
Traceback (most recent call last):
  File "/usr/local/System/main.py", line 20, in <module>
    from LightUpAlarm import AlarmCli
  File "/usr/local/System/LightUpAlarm/AlarmCli.py", line 26, in <module>
    from AlarmManager import AlarmManager
ImportError: No module named AlarmManager

并在web.xml中注册

import com.googlecode.objectify.ObjectifyService;

public class StartupServlet extends HttpServlet {

  static {
    ObjectifyService.register(Profile.class);
  }
}

编辑:

我想你已经在你的代码片段中再次从谷歌库中导入了你的,将其改为:

<servlet>
    <servlet-name>startup</servlet-name>
    <servlet-class>full.package.StartupServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>