Objectify + Eclipse + Generate Cloud Endpoint客户端库:“变量不符合样式指南”

凡妮莎2

我正在使用的是:Eclipse,Java,Objectify,Google App Engine SDK

如果这个问题已经解决,我感到抱歉。但是我找不到任何解决方案。情况如下:

我尝试了大约3个星期才能使我的项目正常进行。一开始,我有一个Android项目。然后,通过Google Eclipse插件,我在Eclipse上生成了一个App Engine后端,并开始使用JPA。但是,我在关系方面有太多问题。我只是失去了时间和耐心。因此,我决定采取客观化措施。

我按照Objectify文档的所有步骤构建了类。我定义了端点,用新的替换了以前的代码(使用JPA的代码)。objectify和guava jars都在WEB-INF / lib上并且在构建路径中。

问题:当我尝试生成Cloud Endpoint Client Libraries时,出现以下错误:

为您的Cloud Endpoints类生成API元数据时出现问题:

com.google.appengine.repackaged.com.google.api.client.http.HttpResponseException: 
400 Bad Request
{"error": {"message": "Bad Request", "code": 400, "errors": [{"message": "api exception", "debug_info": "Variable  does not conform to style guide"}]}} 

错误日志:

java.lang.reflect.InvocationTargetException
    at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiAction$1.run(GenerateSwarmApiAction.java:82)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmGenerationException: com.google.appengine.repackaged.com.google.api.client.http.HttpResponseException: 400 Bad Request
{"error": {"message": "Bad Request", "code": 400, "errors": [{"message": "api exception", "debug_info": "Variable  does not conform to style guide"}]}}
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:144)
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createSwarmApi(SwarmApiCreator.java:258)
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmServiceCreator.create(SwarmServiceCreator.java:444)
    at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiAction$1.run(GenerateSwarmApiAction.java:80)
    ... 1 more
Caused by: com.google.appengine.repackaged.com.google.api.client.http.HttpResponseException: 400 Bad Request
{"error": {"message": "Bad Request", "code": 400, "errors": [{"message": "api exception", "debug_info": "Variable  does not conform to style guide"}]}}
    at com.google.appengine.repackaged.com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1054)
    at com.google.api.server.spi.tools.CloudClientLibGenerator.postRequest(CloudClientLibGenerator.java:53)
    at com.google.api.server.spi.tools.CloudClientLibGenerator.generateClientLib(CloudClientLibGenerator.java:44)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:142)
    ... 4 more
Root exception:
com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmGenerationException: com.google.appengine.repackaged.com.google.api.client.http.HttpResponseException: 400 Bad Request
{"error": {"message": "Bad Request", "code": 400, "errors": [{"message": "api exception", "debug_info": "Variable  does not conform to style guide"}]}}
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:144)
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createSwarmApi(SwarmApiCreator.java:258)
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmServiceCreator.create(SwarmServiceCreator.java:444)
    at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiAction$1.run(GenerateSwarmApiAction.java:80)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: com.google.appengine.repackaged.com.google.api.client.http.HttpResponseException: 400 Bad Request
{"error": {"message": "Bad Request", "code": 400, "errors": [{"message": "api exception", "debug_info": "Variable  does not conform to style guide"}]}}
    at com.google.appengine.repackaged.com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1054)
    at com.google.api.server.spi.tools.CloudClientLibGenerator.postRequest(CloudClientLibGenerator.java:53)
    at com.google.api.server.spi.tools.CloudClientLibGenerator.generateClientLib(CloudClientLibGenerator.java:44)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createClientLibFromApiConfig(SwarmApiCreator.java:142)
    ... 4 more

一些示例(包括实体注册)。我将取消打包,导入和获取/设置程序。如果有人知道如何提供帮助,我将不胜感激。如果我应该在此处输入任何代码,请告诉我。

User.java

@Entity
    public class User {
    @Id
    private Long id;

    private String name;

    @Index
    private PhoneNumber phoneNumber;

    private String friendCode;

    @Load
    private List<Ref<Group>> groups = new ArrayList<Ref<Group>>(); //groups that a User can be simple member

    //...
    }

Group.java

@Entity
public class Group {
    @Id
    private Long id;

    @Index(IfNotNull.class)
    private String name;

    @Load
    @Index
    private Ref<User> owner; // Owner of the group. The creator.

OfyService.java

import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;

public class OfyService {
    static {
        factory().register(Group.class);
        factory().register(User.class);      
    }

    public static Objectify ofy() {
        return ObjectifyService.ofy();
    }

    public static ObjectifyFactory factory() {
        return ObjectifyService.factory();
    }
}

UserEndpoint.java

import static com.uandq.lychee.OfyService.ofy;
@Api(name = "sampleEndpoint", namespace = @ApiNamespace(ownerDomain = "sample.com", ownerName = "sample.com", packagePath = ""))
public class UserEndpoint {


    @ApiMethod(name = "listUser")
    public List<User> listUser() {
        List<User> result = new ArrayList<User>();
        result = ofy().load().type(User.class).list();
        return result;
    }

    @ApiMethod(name = "getUser")
    public User getUser(@Named Long id) {
        User user = ofy().load().type(User.class).id(id).now();
        return user;
    }

    @ApiMethod(name = "insertUser")
    public User insertUser(User user) {
        ofy().save().entity(user).now();
        return user;
    }

    @ApiMethod(name = "removeUser")
    public void removeUser(@Named Long id) {
        ofy().delete().type(User.class).id(id).now();
    }

    @ApiMethod(name = "findUserByPhoneNumber")
    public User findUserByPhoneNumber(PhoneNumber phone) {

        User user = ofy().load().type(User.class)
                .filter("phoneNumber ==", phone).first().now();

        return user;
    }
}

GroupEndpoint.java

import static com.uandq.lychee.OfyService.ofy;

@Api(name = "sampleEndpoint", namespace = @ApiNamespace(ownerDomain = "sample.com", ownerName = "sample.com", packagePath = ""))
public class GroupEndpoint {

    @ApiMethod(name = "listGroup")
    public List<Group> listGroup() {
        List<Group> result = new ArrayList<Group>();
        result = ofy().load().type(Group.class).list();
        return result;
    }

    @ApiMethod(name = "getGroup")
    public Group getGroup(@Named Long id) {
        Group group = ofy().load().type(Group.class).id(id).now();
        return group;
    }

    @ApiMethod(name = "insertGroup")
    public Group insertGroup(Group group) {
        ofy().save().entity(group).now();
        return group;
    }

    @ApiMethod(name = "removeGroup")
    public void removeGroup(@Named Long id) {
        ofy().delete().type(Group.class).id(id).now();
    }

}

web.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app version="2.5">
    <servlet>
        <servlet-name>SystemServiceServlet</servlet-name>
        <servlet-class>com.google.api.server.spi.SystemServiceServlet
        </servlet-class>
        <init-param>
            <param-name>services</param-name>
            <param-value>com.sample.GroupEndpoint, com.sample.UserEndpoint</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>SystemServiceServlet</servlet-name>
        <url-pattern>/_ah/spi/*</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>ObjectifyFilter</filter-name>
        <filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>ObjectifyFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

另外,我现在尝试按照以下步骤生成Endpoint库:通过Terminals使用endpoints.sh为Android生成客户端库。而且效果不佳。我仍然得到:

Error: 400 Bad Request

{"error": {"message": "Bad Request", "code": 400, "errors": [{"message": "api exception", "debug_info": "Variable  does not conform to style guide"}]}}

欢迎任何帮助。该问题还发布在:https : //groups.google.com/forum/?hl=zh-CN#!topic/objectify- appengine/ 981f4LlXscg

凡妮莎2

现在的问题已解决。

解决方案:https : //groups.google.com/forum/?hl=zh-CN#!topic/objectify- appengine/ 981f4LlXscg

我发现了问题。实际上,我关注了此链接https://cloud.google.com/developers/articles/google-cloud-endpoints-for-android上的所有内容然后,有:

大多数参数类型必须可序列化,因为JSON要求对象可序列化。您还可以使用任何JavaBean,其中包括模型中的所有内容,因为模型对象应符合如上所述的JavaBean标准。一组有限的 类型不必可序列化,但必须使用@Named进行注释。这些类型是:字符串,整数/整数,布尔值/布尔值,长整数/长整数。

在我的端点中,某些参数以错误的方式使用了@Named注释:没有参数的实际名称。我什至不需要实现Serializable。我只是替换了:

public User getUser(@Named Long id)

通过

public User getUser(@Named("id") Long id)

以及所有其他@Named参数。现在,我可以生成端点库了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Objectify + Eclipse + Generate Cloud Endpoint客户端库:“变量不符合样式指南”

来自分类Dev

Objectify和Google Cloud端点示例

来自分类Dev

Objectify客户端的多态性(android / ios)

来自分类Dev

如何通过JDO,JPA或Objectify访问Google Cloud Datastore?

来自分类Dev

预热请求在 Cloud Endpoints Objectify 中不起作用

来自分类Dev

具有objectify的GAE端点(Java)-如何为部分数据建模(针对客户端)?

来自分类Dev

具有objectify的GAE端点(Java)-如何为部分数据建模(针对客户端)?

来自分类Dev

如何使用Objectify从Cloud Datastore加载给定类型的所有实体?

来自分类Dev

Google Cloud Datestore-无法在Objectify v5上使用游标

来自分类Dev

Objectify 中的延迟保存是否适用于每个 Java 实体或每个 Google Cloud Datastore 实体?

来自分类Dev

Google Endpoint + Objectify + Android过滤器或搜索

来自分类Dev

可以在GAE之外使用Objectify库吗?

来自分类Dev

提供祖先是否会提高objectify / google cloud数据存储区中的过滤器查询性能?

来自分类Dev

客户端与客户端与Cloud Endpoints的通信

来自分类Dev

客户端与客户端与Cloud Endpoints的通信

来自分类Dev

在eclipse中附加客户端进程

来自分类Dev

在GAE中创建Google Cloud Endpoint时出现项目错误(Eclipse)

来自分类常见问题

Firebase Cloud Messaging Java客户端

来自分类Dev

Google Cloud Storage客户端

来自分类Dev

基本的流星用户订阅不符合客户端服务器的要求

来自分类Dev

如何使用 Eclipse 将数据插入到 Google Cloud mysql 数据库中

来自分类Dev

如何获取Eclipse Paho MQTT C客户端的静态库?

来自分类Dev

无法在Android项目中导入Google Cloud Endpoints客户端库类

来自分类Dev

Android Studio:“安装客户端库”在哪里用于Cloud Endpoints?

来自分类Dev

Cloud SQL数据库无法从mysql客户端连接

来自分类Dev

Cloud Storage Python客户端库需要Ubuntu 14.04 VM实例上的Memcache代理

来自分类Dev

通过Gradle使用“ Java的Google Cloud Datastore API客户端库”

来自分类Dev

为Cloud Endpoints Frameworks 2.0生成客户端库时出错

来自分类Dev

将 bluebirdjs 与 Google Cloud Datastore 节点客户端库结合使用

Related 相关文章

  1. 1

    Objectify + Eclipse + Generate Cloud Endpoint客户端库:“变量不符合样式指南”

  2. 2

    Objectify和Google Cloud端点示例

  3. 3

    Objectify客户端的多态性(android / ios)

  4. 4

    如何通过JDO,JPA或Objectify访问Google Cloud Datastore?

  5. 5

    预热请求在 Cloud Endpoints Objectify 中不起作用

  6. 6

    具有objectify的GAE端点(Java)-如何为部分数据建模(针对客户端)?

  7. 7

    具有objectify的GAE端点(Java)-如何为部分数据建模(针对客户端)?

  8. 8

    如何使用Objectify从Cloud Datastore加载给定类型的所有实体?

  9. 9

    Google Cloud Datestore-无法在Objectify v5上使用游标

  10. 10

    Objectify 中的延迟保存是否适用于每个 Java 实体或每个 Google Cloud Datastore 实体?

  11. 11

    Google Endpoint + Objectify + Android过滤器或搜索

  12. 12

    可以在GAE之外使用Objectify库吗?

  13. 13

    提供祖先是否会提高objectify / google cloud数据存储区中的过滤器查询性能?

  14. 14

    客户端与客户端与Cloud Endpoints的通信

  15. 15

    客户端与客户端与Cloud Endpoints的通信

  16. 16

    在eclipse中附加客户端进程

  17. 17

    在GAE中创建Google Cloud Endpoint时出现项目错误(Eclipse)

  18. 18

    Firebase Cloud Messaging Java客户端

  19. 19

    Google Cloud Storage客户端

  20. 20

    基本的流星用户订阅不符合客户端服务器的要求

  21. 21

    如何使用 Eclipse 将数据插入到 Google Cloud mysql 数据库中

  22. 22

    如何获取Eclipse Paho MQTT C客户端的静态库?

  23. 23

    无法在Android项目中导入Google Cloud Endpoints客户端库类

  24. 24

    Android Studio:“安装客户端库”在哪里用于Cloud Endpoints?

  25. 25

    Cloud SQL数据库无法从mysql客户端连接

  26. 26

    Cloud Storage Python客户端库需要Ubuntu 14.04 VM实例上的Memcache代理

  27. 27

    通过Gradle使用“ Java的Google Cloud Datastore API客户端库”

  28. 28

    为Cloud Endpoints Frameworks 2.0生成客户端库时出错

  29. 29

    将 bluebirdjs 与 Google Cloud Datastore 节点客户端库结合使用

热门标签

归档