GAE Cloud Endpoint Error Generating Client Libraries - java.lang.IllegalArgumentException

0 views
Skip to first unread message

user2556560 via StackOverflow

unread,
Jul 6, 2013, 12:22:33 PM7/6/13
to google-appengin...@googlegroups.com

I am playing around with GAE Cloud endpoints and Datastore following all of the examples on the developers site. I am getting an error I cannot resolve when generating the the client libraries:

"Exception in thread "main" java.lang.IllegalArgumentException: Parameterized type interface java.lang.Iterable not supported..."

Can anyone tell me why I am getting the error and how to fix it?

Here is my code:

**Util.java**
package com.davozardini.myfisrtapp;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.FilterOperator;

/**
 * This is the utility class for entity operation methods.
 * 
 */
public class Util {

private static final Logger logger = Logger.getLogger(Util.class.getCanonicalName());
private static DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();


/**
* 
* @param entity  : entity to be persisted
*/
 public static void persistEntity(Entity entity) {
    logger.log(Level.INFO, "Saving entity");
    datastore.put(entity);      
 }


/**
* Delete the entity from persistent store represented by the key
* @param key : key to delete the entity from the persistent store
*/
 public static void deleteEntity(Key key) {
    logger.log(Level.INFO, "Deleting entity");
    datastore.delete(key);      
  }

 /**
 * Search and return the entity from datastore.
 * @param key : key to find the entity
 * @return  entity
 */
 public static Entity findEntity(Key key) {
    logger.log(Level.INFO, "Search the entity");
    try {     
      return datastore.get(key);
    } catch (EntityNotFoundException e) {
      return null;
    }
  }

 /***
     * Search entities based on search criteria
     * @param kind
     * @param searchBy
     *            : Searching Criteria (Property)
     * @param searchFor
     *            : Searching Value (Property Value)
     * @return List all entities of a kind from the cache or datastore (if not
     *         in cache) with the specified properties
     */
 public static Iterable<Entity> listEntities(String kind) {
    logger.log(Level.INFO, "Search entities based on search criteria");

    Query q = new Query(kind);              
    PreparedQuery pq = datastore.prepare(q);
    return pq.asIterable();
  }


}

Person.java package com.davozardini.myfisrtapp;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.davozardini.myfisrtapp.Util;

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.AnnotationBoolean;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiMethod.HttpMethod;
import javax.inject.Named;

@Api(
    name = "Person",
    version = "v1",
    description = "myfisrtapp Person API",      
    defaultVersion = AnnotationBoolean.TRUE
)


/**
 * This class handles all the CRUD operations related to
 * People entity.
 *
 */
public class Person {


/**
 * Get all Person entities
 * @return: Iterable<Entity> entities
 */
@ApiMethod(
        name = "Person.getAllPersons",
        path = "Person",
        httpMethod = HttpMethod.GET
     )
 public static Iterable<Entity> getAllPersons() {
     Iterable<Entity> entities = Util.listEntities("Person");
     return entities;       
 }

 /**
   * Get Person entity
   * @param name : key of the Person
   * @return: Person entity
   */
  public static Entity getPerson(@Named("name")String name) {
    Key key = KeyFactory.createKey("Person",name);
    return Util.findEntity(key);
  }

/**
 * Update the product
 * @param name: name of the product
 * @param description : description
 * @return  updated product
 */
  public static void createPerson(@Named("name")String name, @Named("description")String description) {
    Entity person = new Entity("Person");
    person.setProperty("name", name);
    person.setProperty("description", description);
    Util.persistEntity(person);
  }       

}


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/17504766/gae-cloud-endpoint-error-generating-client-libraries-java-lang-illegalargument

tony via StackOverflow

unread,
Jul 6, 2013, 3:12:37 PM7/6/13
to google-appengin...@googlegroups.com

Please try adding these imports java.lang.iterable , com.google.common.collect.Iterables to your util.java



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/17504766/gae-cloud-endpoint-error-generating-client-libraries-java-lang-illegalargument/17506162#17506162
Reply all
Reply to author
Forward
0 new messages