asolfre / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
0 stars 0 forks source link

Remote API seems not to work in Objectify 4 #145

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Deploy GAE application with RemoteAPI servlet handler
2. Deploy or run locally second GAE application
3. Try to fetch remote data running the following snippet of code:

static {
   ObjectifyService.register(Item.class);
}

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws 
IOException {
   RemoteApiOptions options = new RemoteApiOptions().server(appId, 443).credentials(username, password);

   installer = new RemoteApiInstaller();
   installer.install(options);

   Key<Item> itemKey =  Key.create(Item.class, itemId);

   //item is null, despite it is present is remote datastore
   Item item = ofy().load().key(itemKey ).getValue();

   com.google.appengine.api.datastore.Key itemRawKey = itemKey.getRaw();

   Consistency consistency = Consistency.STRONG;
   DatastoreServiceConfig cfg = DatastoreServiceConfig.Builder.withReadPolicy(new ReadPolicy(consistency));   
   AsyncDatastoreService datastoreService = DatastoreServiceFactory.getAsyncDatastoreService(cfg);

   //entity is non-null as expected
   Entity entity = datastoreService.get(itemRawKey).get();
}

What is the expected output? What do you see instead?
   Entity loaded via objectify is null despite the same query via low-level API works as expected.

What version of the product are you using? On what operating system?
   - objectify-4.0b1
   - AppEngine SDK 1.7.4
   - Windows 8 x64

Please provide any additional information below.
   - Registering entity at the moment RemoteApiInstaller has been already installed doesn't help
   - The code above doesn't work both locally and deployed

Original issue reported on code.google.com by PeterTur...@gmail.com on 2 Feb 2013 at 2:14

GoogleCodeExporter commented 9 years ago
I cannot explain this; I use the remote API with Objectify frequently. As do 
other people. Perhaps start a discussion on the google group?

Original comment by lhori...@gmail.com on 29 Mar 2013 at 8:05

GoogleCodeExporter commented 9 years ago
Hi Jeff, thank you for involvement, i'll create a discussion on the gp today.

Original comment by p...@cloudwk.com on 30 Mar 2013 at 10:40

GoogleCodeExporter commented 9 years ago
I have the same problem, fetching for lists works fine, however fetches using 
ID are null at now().  Ref() seems to have result thought when debugging.

-- HAS RESULTS --
Objectify ofy = factory( ).begin( ).cache( false ).consistency( 
Consistency.STRONG ).deadline( 10.0 );
return ofy.load( ).type( ClientJsonFile.class ).order( "filenameId" ).list( ); 
<- good

-- NO RESULT --
Objectify ofy = factory( ).begin( ).cache( false ).consistency( 
Consistency.STRONG ).deadline( 10.0 );
return ofy.load( ).type( ClientJsonFile.class ).id( id ).get( );

Original comment by rxre...@gmail.com on 3 May 2013 at 10:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It looks like LoadEngine makes two passes/rounds when fetching.  I noticed that 
Round 1 cause Round 2 to be fired.  Round 2 indeed has the result of the query, 
however Round 1 is the method that returns up the stack.  Round 1 always 
remains null with no context.

Original comment by rxre...@gmail.com on 3 May 2013 at 11:31

Attachments:

GoogleCodeExporter commented 9 years ago
rxreyn3, are you having a problem with the remote api?  Are you certain your 
class doesn't have a @Parent?

If you believe you have an issue, you will need to create a test case. There 
are extensive tests of basic features like fetching and they all work. They 
also work in many live production systems. You should consider posting to the 
objectify google group.

The LoadEngine behavior is not easy to understand and without more information 
it's not clear that these screenshots demonstrate any kind of problem. An 
isolated test case is necessary.

Original comment by lhori...@gmail.com on 4 May 2013 at 8:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Yes, we are using the Remote API to access the datastore of our PROD server.  
None of our kinds have parents.
I also have the Objectify filter enabled for the remote_api/ URI.

I was able to find a workaround by calling .filterKey() with a Key instead of 
.id().  I noticed that, when using .filterKey(), only a single "round" was 
executed as opposed to two rounds using the latter method.

Anyway, works now, sounds like it could be just me seeing this so I won't post 
to group.  Thanks for help.

Original comment by rxre...@gmail.com on 5 May 2013 at 5:32

GoogleCodeExporter commented 9 years ago
I experience absolutely the same issue. My entity has only one field: Id. All 
works perfectly fine when I use local datastore, and I get null with remote api.

Original comment by mshme...@gmail.com on 15 Jul 2013 at 3:14