A project ID is required for this service but could not be determined from the builder or the environment

450 views
Skip to first unread message

Gregory Was via StackOverflow

unread,
Apr 17, 2016, 2:14:03 AM4/17/16
to google-appengin...@googlegroups.com

I'm trying to insert data to Google Datastore and i'm getting bellow error:

java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment. Please set a project ID using the builder. at com.google.common.base.Preconditions.checkArgument(Preconditions.java:92) at com.google.cloud.ServiceOptions.(ServiceOptions.java:324) at com.google.cloud.datastore.DatastoreOptions.(DatastoreOptions.java:85) at com.google.cloud.datastore.DatastoreOptions.(DatastoreOptions.java:32) at com.google.cloud.datastore.DatastoreOptions$Builder.build(DatastoreOptions.java:75) at com.google.cloud.datastore.DatastoreOptions.defaultInstance(DatastoreOptions.java:123)

CODE is:

Datastore datastore = DatastoreOptions.defaultInstance().service();     
             KeyFactory keyFactory = datastore.newKeyFactory().kind("keyKind"); 
             Key key = keyFactory.newKey("keyName"); 
             Entity entity = Entity.builder(key) 
                 .set("name", "John Doe") 
                 .set("age", 30) 
                 .set("access_time", DateTime.now()) 
                 .build(); 
             datastore.put(entity); 


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/36673248/a-project-id-is-required-for-this-service-but-could-not-be-determined-from-the-b

ozarov via StackOverflow

unread,
Apr 17, 2016, 4:44:04 PM4/17/16
to google-appengin...@googlegroups.com

Are you running AE standard or AE Flexible?

Make sure you have the App Engine api jar in your classpath (WEB-INF/lib directory).



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/36673248/a-project-id-is-required-for-this-service-but-could-not-be-determined-from-the-b/36681969#36681969
Reply all
Reply to author
Forward
0 new messages