Google App Engine does not recognized @Named parameter

60 views
Skip to first unread message

Lucas Layman

unread,
Sep 20, 2016, 7:27:37 PM9/20/16
to Google App Engine
I am using the [Google Plugin for Eclipse][1], and I am writing an App Engine app as a Dynamic Web Module in Eclipse WTP.

I have defined the following Java class to serve as a Cloud Endpoint API:

package mypackage;

import static mypackage.OfyService.ofy;

import java.util.List;
import java.util.logging.Logger;

import mypackage.models.ProbeEntry;
import mypackage.models.ProbeSet;

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.config.Named;
import com.googlecode.objectify.ObjectifyService;

@Api(name = "analysisEndpoint",
        version = "v1",
        namespace = @ApiNamespace(
                                                           ownerDomain = "myorg",
                                                            ownerName = "myorg",
                                                              packagePath = "analysis")
              )
public class AnalysisEndpoint {

       @ApiMethod(name = "getMyProbeEntries", httpMethod = ApiMethod.HttpMethod.GET)
       public ProbeSet getMyProbeEntries(@Named("amount") int amount) {
               ObjectifyService.begin();

                List<ProbeEntry> probeList = ofy().load().type(ProbeEntry.class).limit(amount).list();

                return new ProbeSet(probeList);
}
}


I attempt to deploy to the Google App Engine by right-clicking the project -> Google App Engine WTP -> Deploy Project to Remote Server. I see in my console that the project is compiling and uploading, but eventually errors out with:

99% Endpoints configuration not updated.  The app returned an error when the Google Cloud Endpoints server attempted to communicate with it.

The error log on the app engine shows the following:
    18:31:58.119
javax.servlet.ServletContext log: unavailable
        com.google.api.server.spi.config.validation.MissingParameterNameException: analysisEndpoint.myorg.analysis.AnalysisEndpoint.getMyProbeEntries parameter (type int): Missing parameter name. Parameter type (int) is not an entity type and thus should be annotated with @Named.
at     
        com.google.api.server.spi.config.validation.ApiConfigValidator.validateApiParameter(ApiConfigValidator.java:214)
...

As can be seen in the code, I do have `@Named("amount")` before the offending parameter. What is going wrong here? Side note: If I simply remove the `amount` parameter, the project deploys to App Engine without a problem.

Any help would be greatly appreciated.

Nick (Cloud Platform Support)

unread,
Sep 22, 2016, 7:54:33 PM9/22/16
to Google App Engine
Hey Lucas,

Which version of the App Engine SDK is your java project compiling against? It does seem odd that the parameter's annotation should not be recognized.

Cheers,

Nick
Cloud Platform Community Support
Reply all
Reply to author
Forward
0 new messages