使用Google Eclipse插件干扰谷歌云端点的方法 [英] Method interference in Google Cloud Endpoints with Google Eclipse Plugin

查看:168
本文介绍了使用Google Eclipse插件干扰谷歌云端点的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Google Appengine Eclipse插件生成端点时,我遇到了一个奇怪的行为。我有一个包含20多个端点方法的端点类。当我第一次尝试为android生成端点时,我得到错误

 生成云端点遇到错误并且不完整

通过故障排除,我将所有方法注释掉以找到罪魁祸首。我发现有点莫名其妙。取消第16种方法后,我再次得到错误。有两种方法互相干扰!如果我将其中一个或另一个注释掉,则端点生成正常。但是,如果我没有注释,我得到上述错误。



有人知道可能会造成这种干扰吗?

  @ApiMethod(name =getOrangers,httpMethod = HttpMethod.POST)
公共FaceList getOrangers(UserRequest请求)抛出NotFoundException {
FaceList list = new FaceList ();
返回列表;
}

@ApiMethod(name =getMangoers,httpMethod = HttpMethod.POST)
public FaceList getMangoers(UserRequest request)throws NotFoundException {
FaceList list = new后才可以();
返回列表;
}

我已经将方法编辑到它们的存根,如上所示,仍然得到同样的干扰问题。

解决方案

首先,当您遇到令人讨厌的不良信息时发生错误:


生成云端点遇到错误并且未完成

您应该检查窗口 - >下的错误日志显示视图 - >错误日志以获得更多信息。






我这样做了,我发现实际例外是:

pre $ java.lang.IllegalArgumentException:
具有相同休息路径的多个方法POST facelist:getOrangers 和getMangoers

所以问题在于你的2个方法具有相同的路径!为您的方法显式添加一个路径将解决问题:

  @ApiMethod(name =getOrangers,path =get_oranges ,httpMethod = HttpMethod.POST)
public FaceList getOrangers(UserRequest request)throws NotFoundException {
// ...
}

@ApiMethod(name =getMangoers ,path =get_mangoers,httpMethod = HttpMethod.POST)
public FaceList getMangoers(UserRequest request)throws NotFoundException {
// ...
}


$ b

注意::因为您没有为您设置路径方法,GPE会自动生成它们。看起来GPE为这两种方法生成了相同的路径,用于形成HTTP方法( POST )和返回值( facelist )的路径, t符合 Google Cloud Endpoints文档中的说明
$ b


路径:用于访问此方法的URI路径。您不设置
this,基于Java 方法名称使用默认路径。


它表示路径是使用方法名自动生成的,在这种情况下,您不会收到任何错误,因为您的2个方法的名称明显不同。所以我猜想这肯定是一个错误(和其他许多人一样)。


I am experiencing a strange behavior while generating endpoints using the Google Appengine Eclipse plugin. I have an endpoint class with over 20 endpoint methods. When I first tried generating the endpoints for android I get the error

 Generating Cloud Endpoint has encountered errors and is not complete

By way of troubleshooting, I comment out all the methods to find the culprits. What I found is a bit baffling. After uncommenting the 16th method, I get the error again. There are two methods that are interfering with each other! If I comment out one or the other the endpoint is generated fine. But if I have both uncommented, I get the error above.

Does anyone know what may be causing this interference?

@ApiMethod(name = "getOrangers", httpMethod = HttpMethod.POST)
public FaceList getOrangers(UserRequest request) throws NotFoundException {
    FaceList list = new FaceList();
    return list;
}

@ApiMethod(name = "getMangoers", httpMethod = HttpMethod.POST)
public FaceList getMangoers(UserRequest request) throws NotFoundException {
    FaceList list = new FaceList();
    return list;
}

I have edited the methods down to their stubs as shown above and still get the same interference problem.

解决方案

Firstly, when you get an error with that annoying undescriptive message:

Generating Cloud Endpoint has encountered errors and is not complete

you should check the Error Log under Window -> Show View -> Error Log to get more info.


I did so, and I found that the actual exception is:

java.lang.IllegalArgumentException: 
  Multiple methods with same rest path "POST facelist": "getOrangers" and "getMangoers"

So, the problem is that your 2 methods have the same path! Adding explicitly a path for your methods will solve the problem:

@ApiMethod(name="getOrangers", path="get_oranges", httpMethod=HttpMethod.POST)
public FaceList getOrangers(UserRequest request) throws NotFoundException {
    //...
}

@ApiMethod(name="getMangoers", path="get_mangoers", httpMethod=HttpMethod.POST)
public FaceList getMangoers(UserRequest request) throws NotFoundException {
    //...
}


NOTE: As you didn't set paths for your methods, GPE is generating them automatically. It seems that GPE is generating the same path for the 2 methods, using to form the path the HTTP method (POST) and the returned value (facelist), which doesn't correspond with what is said in Google Cloud Endpoints Documentation:

"path: The URI path to use to access this method. If you don't set this, a default path is used based on the Java method name."

It says that the path is automatically generated using the method name, and in that case you'd not getting any error, since your 2 methods have obviously different names. So I guess it must be a bug (as many others) in Endpoints.

这篇关于使用Google Eclipse插件干扰谷歌云端点的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆