InvocationTargetException when generating cloud endpoint class

20 views
Skip to first unread message

Chuck Onwuzuruike via StackOverflow

unread,
Mar 1, 2015, 1:39:06 AM3/1/15
to google-appengin...@googlegroups.com

When I click to generate cloud endpoint client library, I receive the following on the error log.

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:122)
Caused by: com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmGenerationException: com.google.api.server.spi.config.validation.MissingParameterNameException: tuberservice.com.rune.tuber.server.TuberServiceImpl.TuberServiceImpl.getInitParameter parameter (type class java.lang.String): Missing parameter name. Parameter type (class java.lang.String) is not an entity type and thus should be annotated with @Named.
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createSwarmApi(SwarmApiCreator.java:292)
    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.api.server.spi.config.validation.MissingParameterNameException: tuberservice.com.rune.tuber.server.TuberServiceImpl.TuberServiceImpl.getInitParameter parameter (type class java.lang.String): Missing parameter name. Parameter type (class java.lang.String) is not an entity type and thus should be annotated with @Named.
    at com.google.api.server.spi.config.validation.ApiConfigValidator.validateApiParameter(ApiConfigValidator.java:271)
    at com.google.api.server.spi.config.validation.ApiConfigValidator.validateParameter(ApiConfigValidator.java:229)
    at com.google.api.server.spi.config.validation.ApiConfigValidator.validateMethod(ApiConfigValidator.java:169)
    at com.google.api.server.spi.config.validation.ApiConfigValidator.validateMethods(ApiConfigValidator.java:130)
    at com.google.api.server.spi.config.validation.ApiConfigValidator.validate(ApiConfigValidator.java:93)
    at com.google.api.server.spi.config.validation.ApiConfigValidator.validate(ApiConfigValidator.java:63)
    at com.google.api.server.spi.config.jsonwriter.JsonConfigWriter.writeConfig(JsonConfigWriter.java:102)
    at com.google.api.server.spi.tools.AnnotationApiConfigGenerator.generateConfig(AnnotationApiConfigGenerator.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gdt.eclipse.appengine.swarm.wizards.helpers.SwarmApiCreator.createSwarmApi(SwarmApiCreator.java:288)
    ... 3 more

Here is my service implementation

@SuppressWarnings("serial")
@Api(name = "tuberservice")
public class TuberServiceImpl extends RemoteServiceServlet implements
        TuberService {

    @Override
    @ApiMethod(name = "addClient")
    public String addClientService(TuberClient t) {
        if (t != null){
            PersistenceManager pm = PMF.get().getPersistenceManager();
            pm.makePersistent(t);
            pm.close();
            return t.toString();
        }
        return "Invalid client";
    }

    @SuppressWarnings("unchecked")
    @Override
    @ApiMethod(name = "listClients")
    public TuberClient[] listAllClientsService() {
        // TODO Auto-generated method stub
        //select from TuberClient
        PersistenceManager pm = PMF.get().getPersistenceManager();
        Query q = pm.newQuery(TuberClient.class);
        List<TuberClient> list = (List<TuberClient>) q.execute();
        ArrayList<TuberClient> returnList = new ArrayList<TuberClient>();
        for (TuberClient t : list){
            returnList.add(t);
        }//end for
        pm.close();
        return (TuberClient[])returnList.toArray(new TuberClient[0]);
    }

}

I've been looking for a solution to the problem for hours now. I tried reverting to appengine1.8.8 and it didnt work, I tried rebuilding, cleaning, etc, didnt and I even tried deploying to appengine and that didn't work.

I literally don't know where to begin to resolve the error because i DO NOT have any strings in my server implementation to annotate so Im overall very confused.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/28790845/invocationtargetexception-when-generating-cloud-endpoint-class

tomrozb via StackOverflow

unread,
Mar 1, 2015, 2:59:07 AM3/1/15
to google-appengin...@googlegroups.com

You cannot return String from Cloud Endpoints methods.

This line will not compile:

public String addClientService(TuberClient t)

Please read this guide. Double check your code if it returns valid values and every required parameter has it corresponding @Name annotation.

In the Endpoint methods, the return value type cannot be simple type such as String or int. The return value needs to be a POJO, an array or a Collection. Also, list() and get() are exposed as HTTP GETs, insert() is exposed as a HTTP POST, update() is exposed as a HTTP PUT, and removeNote() is exposed as a HTTP DELETE.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/28790845/invocationtargetexception-when-generating-cloud-endpoint-class/28791353#28791353

tomrozb via StackOverflow

unread,
Mar 1, 2015, 5:19:10 AM3/1/15
to google-appengin...@googlegroups.com

You cannot return String from Cloud Endpoints methods.

This line will not compile:

public String addClientService(TuberClient t)

This is also suspicious:

extends RemoteServiceServlet implements TuberService

Check if you don't have any API methods there which returns String.

Reply all
Reply to author
Forward
0 new messages