Tadas Davidsonas
Tadas Davidsonas

Reputation: 1929

The error creating app Engine's DataStore Entity within GWT app

I try to create the entity like this:

DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity stock = new Entity("Stock", 1);
stock.setProperty("Stock", "FCB");
ds.put(stock);

but keep getting the error:

No source code is available for type com.google.appengine.api.datastore.DatastoreService; did you forget to inherit a required module?

Upvotes: 3

Views: 446

Answers (2)

Anders R. Bystrup
Anders R. Bystrup

Reputation: 16080

The error means just what it says, the GWT compiler needs access to the Java source it compiles to Javascript, and obviously DatastoreService is not something that should exist on the frontend - so you have an architecture issue here.

You'll need to write a proxy that can call a server component (Which in turns calls the DatastoreService) and returns DTOs/value objects (that you define and thus have the source for).

Cheers,

Upvotes: 2

André
André

Reputation: 2204

No source code is available

GWT transliterate Java to Javascript, reading it's source code and there a limited language support.

What you're trying to achieve is a Server only operation and you're adding this operation within the client code, which will run on a browser. Neither GAE allow this or GWT has the source of these classes nor capability to do so.

Solution

You need to create a request to your server that will access the DatastoreService , the return the output to the client code. Below a example of a properly architect GWT web application: GWT Diagram

Upvotes: 1

Related Questions