How to debug errors when Endpoints infrastructure stops generating WEB-INF / *. Api file?

Given a Google Cloud Endpoints project in Eclipse with a servlet class annotated with @Api(name="helloworld")

, the Endpoints framework generates a file named war/WEB-INF/helloworld-v1.api

when the project compiles successfully. Sometimes this file is not generated even if there are no compilation errors, but only what I will call "GAE endpoint code errors".

Example - work:

public class TestEntity {
    public String Text;
    public TestEntity(String text){
        Text = text;
    }
}

@ApiMethod
public TestEntity getTestEntity(){
    return new TestEntity("Hello world"); 
}

      

Example - does NOT work:

// The TestEntity-class is unchanged
@ApiMethod
public TestEntity getTestEntity(String input){
    return new TestEntity("Hello world"); 
}

      

The problem with the last example is that I am taking a String parameter as input without annotating it with @Named

. I know that in this example, but there may be other cases where it is not so obvious.

Is there somewhere where I can read some kind of error log why the .api file is not generated?

Even though I'm a fan of code by convention, it really does take programming efficiency if I can't get feedback on what I am doing wrong. Eclipse provides compiler feedback. The Google Cloud Endpoints framework must provide code-by-rule feedback.

+3


source to share


1 answer


There is currently no good logging or error messages when code generation fails, although this is one (if not most) feature. In the meantime, here's a list of common failure cases:



  • The return type is invalid. Return types must be objects that conform to JavaBean conventions, and types such as Object

    , String

    and Integer

    are not permitted.
  • One or more of the argument types are invalid. Methods can accept at most one object per body POST

    , and that object must also conform to JavaBean conventions. Methods can take zero or more arguments via a query string (using annotation @Named

    ), and they must be scalar types (e.g. String

    , Integer

    ).
  • The API, method, or parameter has an invalid name. API, methods and parameters should be named according to the following regular expression [a-z]+[A-Za-z0-9]*

    . The convention also suggests using it lowerCamelCase

    for naming (although alllowercase

    allowed).
+4


source







All Articles