87

It seems there is no equivalent of Python App Engine's _ah/admin for the Java implementation of Google App Engine.

Is there a manual way I can browse the datastore? Where are the files to be found on my machine? (I am using the App Engine plugin with Eclipse on OS X).

7 Answers 7

111

http://googleappengine.blogspot.com/2009/07/google-app-engine-for-java-sdk-122.html: "At long last, the dev appserver has a data viewer. Start your app locally and point your browser to http://localhost:8888/_ah/admin http://localhost:8000/datastore* to check it out."

* as of 1.7.7

3
  • New admin interface is still not working with kinds/entities created by Native Datastore API. So I still need my "viewer" :)
    – Paul
    Jul 15, 2009 at 10:58
  • 15
    localhost:8888/_ah/admin worked like a champ for me (note the port changed) - but I will try out the AppWrench just for comparison. Apr 30, 2010 at 4:14
  • Thank you so much! I really needed this to debug a persistence issue.
    – SunnyD
    Oct 24, 2012 at 18:04
40

There's currently no datastore viewer for the Java SDK - one should be coming in the next SDK release. In the meantime, your best bet is to write your own admin interface with datastore viewing code - or wait for the next SDK release.

Java App Engine now has a local datastore viewer, accessible at http://localhost:8080/_ah/admin.

4
  • This is redundant -- see dfrankow's post above.
    – Julian H
    Aug 27, 2009 at 9:37
  • 23
    You mean the link to the blog post that was posted several days after I posted this reply? 'outdated' I'll accept, but redundant and voted down is a bit cruel. Aug 27, 2009 at 15:53
  • 1
    I agree. Good answer at the time; now outdated.
    – mcherm
    Oct 25, 2009 at 21:47
  • @mcherm this one worked for me. The other answers here, on the other side, didn't.
    – Johnny
    Jul 27, 2015 at 11:54
6

I have local datastore on my Windows+Eclipse environment on \war\WEB-INF\appengine-generated\local_db.bin

As far as I understood it uses internal format named "protocol buffers". I don't have external tools to present the file in human-readable format.

I'm using simple "viewer" code like this:

public void doGet(HttpServletRequest req, HttpServletResponse resp) 
    throws IOException 
{

    resp.setContentType("text/plain");

    final DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    final Query query = new Query("Table/Entity Name");
    //query.addSort(Entity.KEY_RESERVED_PROPERTY, Query.SortDirection.DESCENDING);

    for (final Entity entity : datastore.prepare(query).asIterable()) {
        resp.getWriter().println(entity.getKey().toString());

        final Map<String, Object> properties = entity.getProperties();
        final String[] propertyNames = properties.keySet().toArray(
            new String[properties.size()]);
        for(final String propertyName : propertyNames) {
            resp.getWriter().println("-> " + propertyName + ": " + entity.getProperty(propertyName));
        }
    }
}
1
  • The code is good, but the parameter for the query constructor is wrong: Table is not correct, it mus be the Entity name. In the guestbook example it would be "greeting" which is the row. I tried this, but not working:final Query query = new Query("Guestbook/Greeting"); Another issue: How do you show the content of different keys/names of a table with your code? Like guestbook1, gb2, etc.
    – Timo
    Mar 12, 2014 at 15:09
2

In the newest versions of the SDK (1.7.6+) the admin part of the dev server comes with it changed its location

Analyzing the server output logs we can see that it is accessible at:

http://localhost:8000

And the Datastore viewer:

http://localhost:8000/datastore

Looks pretty neat - according to google's new design guidlines.

1

Because Google App Engines Datastore viewer does not support displaying collections of referenced entities, I modified Paul's version to display all descendant entities:

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String entityParam = req.getParameter("e");

    resp.setContentType("text/plain");
    final DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    // Original query
    final Query queryOrig = new Query(entityParam);
    queryOrig.addSort(Entity.KEY_RESERVED_PROPERTY, Query.SortDirection.ASCENDING);

    for (final Entity entityOrig : datastore.prepare(queryOrig).asIterable()) {

        // Query for this entity and all its descendant entities and collections
        final Query query = new Query();
        query.setAncestor(entityOrig.getKey());
        query.addSort(Entity.KEY_RESERVED_PROPERTY, Query.SortDirection.ASCENDING);

        for (final Entity entity : datastore.prepare(query).asIterable()) {
            resp.getWriter().println(entity.getKey().toString());

            // Print properties
            final Map<String, Object> properties = entity.getProperties();
            final String[] propertyNames = properties.keySet().toArray(new String[properties.size()]);
            for(final String propertyName : propertyNames) {
                resp.getWriter().println("-> " + propertyName + ": " + entity.getProperty(propertyName));
            }
        }
    }
}

It should be noted that nothing is displayed for empty collections/referenced entities.

1
  • This code looks for all your entities and their child entities, what if the child entities have children too ? will this function run as recursion ? Jan 31, 2016 at 14:14
1

Open the \war\WEB-INF\appengine-generated\local_db.bin file with a text editor, like Notepad++.

The data is scrambled but at least you can read it and you can copy to extract it.

0

For me the fix was to do the login using below gcloud command

gcloud auth application-default login

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.