Google app engine GAE,本地数据存储不创建

Google app engine GAE,本地数据存储不创建,google-app-engine,jpa,intellij-idea,google-cloud-datastore,Google App Engine,Jpa,Intellij Idea,Google Cloud Datastore,我不知道GAE在哪些方面不容易理解: 我的servlet操作一个json字符串,然后我尝试将其存储在数据存储中。 当我运行应用程序时,我得到以下输出: Jan 27, 2014 6:59:04 PM com.google.appengine.api.datastore.dev.LocalDatastoreService load INFO: The backing store, D:\Android\IntelliJ IDEA\workspace\EyeBall\AppEngine\out\ar

我不知道GAE在哪些方面不容易理解:

我的servlet操作一个json字符串,然后我尝试将其存储在数据存储中。 当我运行应用程序时,我得到以下输出:

Jan 27, 2014 6:59:04 PM com.google.appengine.api.datastore.dev.LocalDatastoreService load
INFO: The backing store, D:\Android\IntelliJ IDEA\workspace\EyeBall\AppEngine\out\artifacts\AppEngine_war_exploded\WEB-INF\appengine-generated\local_db.bin, does not exist. It will be created.
1
2
3
4
5
7
***
***
***
***
***
8
9
虽然提到将创建local_db.bin,但当我导航到该目录时,文件不在那里。还有,当我打开http://localhost:8080/_ah/admin/datastore 在浏览器中,实体种类下拉列表中不显示任何内容

那么wtf会发生在当地的垃圾桶里?为什么它不生成? 如有任何建议,将不胜感激。谢谢

================== 更新: 我根据请求添加了代码

    private static final String NO_DEVICE_ID = "FFFF0000";
    private static final String SAMPLE_JSON = "{\"history\":[{\"date\":null,\"info\":null,\"title\":\"Maybank2u.com\",\"url\":\"https://www.maybank2u.com.my/mbb/Mobile/info.do\",\"visits\":14},{\"date\":null,\"info\":null,\"title\":\"Maybank2u.com\",\"url\":\"https://www.maybank2u.com.my/mbb/Mobile/adaptInfo.do\",\"visits\":4},{\"date\":null,\"info\":null,\"title\":\"Maybank2u.com\",\"url\":\"http://www.maybank2u.com.my/mbb_info/m2u/public/personalBanking.do\",\"visits\":16},{\"date\":null,\"info\":null,\"title\":\"Maybank2u.com Online Financial Services\",\"url\":\"https://www.maybank2u.com.my/mbb/m2u/common/M2ULogin.do?action=Login\",\"visits\":52},{\"date\":null,\"info\":null,\"title\":\"‭BBC\",\"url\":\"http://www.bbc.co.uk/persian/\",\"visits\":16}]}";

    private static final String QUERY_HISTORY_DEVICE = "SELECT m FROM HistoryDeviceJPA m WHERE m.userUUID = :keyword ORDER BY m.domain ASC";
    private static final String QUERY_HISTORY        = "SELECT m FROM HistoryJPA m WHERE m.pageAddress = :keyword";

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        displayError(response, "The page doesn't support httpGet");
        String deviceId = NO_DEVICE_ID;
        String content = SAMPLE_JSON;
        System.out.println("1");
        HistoryBrowser historyBrowser = parseJson(content);
        if(historyBrowser == null)
            return;
        System.out.println("2");
        List<HistoryBrowser.BrowserInfo> historyList = historyBrowser.getHistory();
        if(historyList == null)
            return;

        System.out.println("3");

        List<HistoryDeviceJPA> historyDeviceJPAList = new ArrayList<HistoryDeviceJPA>(historyList.size());
        for(int i=0; i<historyList.size(); i++) {
            try {
                HistoryBrowser.BrowserInfo browser = historyList.get(i);
                HistoryDeviceJPA historyDeviceJPA = new HistoryDeviceJPA();
                historyDeviceJPA.setUserUUID(deviceId);
                historyDeviceJPA.setDomain(getDomainName(browser.getUrl()));
                historyDeviceJPA.setPageAddress(browser.getUrl());
                historyDeviceJPA.setPageTitle(browser.getTitle());
                historyDeviceJPA.setPageVisits(browser.getVisits());

                historyDeviceJPAList.add(historyDeviceJPA);

            } catch (URISyntaxException e) {
                System.out.println(e.getMessage());
            }
        }
        System.out.println("4");

        // get history of device from data store
        EntityManager em = EMF.get().createEntityManager();
        Query q = em.createQuery(QUERY_HISTORY_DEVICE).setParameter("keyword", deviceId);
        @SuppressWarnings("unchecked")
        List<HistoryDeviceJPA> dbList = (List<HistoryDeviceJPA>) q.getResultList();

        System.out.println("5");

        // If there is no result (shows there is no record for that device)
        if(dbList == null)
            addHistoryDeviceJPAToDs(historyDeviceJPAList);
        else {
            System.out.println("7");
            // find each item in datastore and replace them if needed
            // if current page visit is less ot equal than previous visit don't do anything (remove item form historyDeviceJPAList)
            outerLoop:
            for(int i=0; i<historyDeviceJPAList.size(); i++) {
                HistoryDeviceJPA deviceItem = historyDeviceJPAList.get(i);
                System.out.println("***");
                for(int j=0; j<dbList.size(); j++) {
                    HistoryDeviceJPA dbItem = dbList.get(j);

                    if(deviceItem.getPageAddress().equalsIgnoreCase(dbItem.getPageAddress())) {
                        if(deviceItem.getPageVisits() > dbItem.getPageVisits()) {
                            long diff = deviceItem.getPageVisits() - dbItem.getPageVisits();
                            dbItem.setPageVisits(deviceItem.getPageVisits());

                            HistoryJPA historyJPA = findHistoryJPA(dbItem.getPageAddress());
                            historyJPA.setPageVisits(historyJPA.getPageVisits() + diff);

                            // update datastore
                            addHistoryDeviceJPAToDs(dbItem);
                            addHistoryJPAToDs(historyJPA);

                            // don't check other items of j list
                            break outerLoop;
                        }
                    }
                }
            }
            System.out.println("8");
        }
        System.out.println("9");
        // http://www.sohailaziz.com/2012/06/scheduling-activities-services-and.html
        // https://dev.twitter.com/docs/api/1.1
        // https://developers.google.com/appengine/docs/java/datastore/jdo/creatinggettinganddeletingdata?csw=1#Updating_an_Object
        // http://en.wikibooks.org/wiki/Java_Persistence/Inheritance
    }
第6条在这里:

private void addHistoryDeviceJPAToDs(List<HistoryDeviceJPA> list) {
        System.out.println("6");
        EntityManager em = EMF.get().createEntityManager();
        try {
            for (int i=0; i<list.size(); i++) {
                System.out.println("=> " + i + " - " + list.get(i).toString());
                em.getTransaction().begin();
                em.persist(list.get(i));
                em.getTransaction().commit();
            }
        } finally {
            em.close();
        }
    }

调试后,我发现问题出在这一行:

List<HistoryDeviceJPA> dbList = (List<HistoryDeviceJPA>) q.getResultList();
        if(dbList == null)
            addHistoryDeviceJPAToDs(historyDeviceJPAList);

对于遇到相同问题的其他人-


在将数据放入数据存储之前,GAE不会创建本地_db.bin。因此,如果文件不存在,则应用程序代码中可能存在错误。

请显示代码的相关部分,以便其他人可以研究或复制效果。您是否确实尝试在代码中保存一些数据?如果数据存储文件在您创建之前没有实际创建,我不会感到惊讶。谢谢@MartinBerends和DanielRoseman。我更新了我的问题。我想既然一切都正常运行,所以代码就没有问题了。如果你有时间,请看一下代码。thx。看起来6是您实际写入数据存储的唯一点,但您的代码从未真正达到6。@PatrickCostello谢谢Patrick,我在回答中解释了这个问题。
List<HistoryDeviceJPA> dbList = (List<HistoryDeviceJPA>) q.getResultList();
        if(dbList == null)
            return;

        System.out.println("5");

        // If there is no result (shows there is no record for that device)
        if(dbList.size() == 0)
            addHistoryDeviceJPAToDs(historyDeviceJPAList);