Atea - Hero's Grave

          面向對象,開源,框架,敏捷,云計算,NoSQL,商業智能,編程思想。

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            40 隨筆 :: 0 文章 :: 28 評論 :: 0 Trackbacks
          當前使用的GAE版本為1.2.1 for java

          1. 使用Eclipse時出現編譯警告(XXX has annotations but there is no registered AnnotationReader. Please check your CLASSPATH and the annotations in the class for validity. )
          解決辦法:修改ORM Enhancement(http://code.google.com/eclipse/docs/appengine_orm.html)
          參考鏈接: http://groups.google.com/group/google-appengine-java/browse_thread/thread/90850aad49730245

          2. 發送郵件時發生com.google.apphosting.api.ApiProxy$CallNotFoundException
          解決辦法:單純的運行郵件發送程序是不行的,需要發布后再執行。如果需要單元測試,需要配置setUp與tearDown
           1     @BeforeTest
           2     public void setUp() throws Exception {
           3         ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
           4         ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")) {});
           5     }
           6     @AfterTest
           7     public void tearDown() throws Exception {
           8         // not strictly necessary to null these out but there's no harm either
           9         ApiProxy.setDelegate(null);
          10         ApiProxy.setEnvironmentForCurrentThread(null);
          11     }
          參考鏈接:http://groups.google.com/group/google-appengine-java/browse_thread/thread/debc5bcb69a6871f

          3. 前臺處理要顯示數據時發生org.datanucleus.exceptions.NucleusUserException
          解決辦法:在PersistenceManager.close()前,使用PersistenceManager.detachCopy(DATA)返回數據

          4. 使用SpringMVC發生java.lang.NoClassDefFoundError: javax/naming/NamingException
          解決辦法:不要使用
          spring all-in-one.jar,使用需要的各個模塊jar
          參考鏈接:http://groups.google.com/group/google-appengine-java/browse_thread/thread/f1a541fe52e172dd

          5. one-to-many情況下使用Collection.add()發生java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
          解決辦法:one的主鍵不要使用Long,使用String或Key等。
          參考鏈接:http://groups.google.com/group/google-appengine-java/browse_thread/thread/10e6cede7fb678f3/62d9505da8ec43bd

          6. 不能插入one-to-many中的many方數據
          解決辦法:JDO這點做的讓人比較不適應,需要手動維護one方的關系才行,具體步驟為:
          a)檢索出one
          b)維護many對象的one關系
          c)維護one對象的many配列關系(重要)
          d)保存
          e)保證以上操作在一個事務中進行
          示例代碼:
          1         Child c = new Child();
          2         PersistenceManager manager = JdoUtil.getPMF().getPersistenceManager();
          3         Parent p = manager.getObjectById(Parent.class, Parent.getId());
          4         c.setParent(p);
          5         p.getChildren().add(c); // important
          6         manager.makePersistent(c);
          7         manager.close();

          GAE for java 還處在發展階段,像JDO/JPA、File upload、image api等的處理還有不少需要完善的地方。
          由上面的第6點可以看出,事務處理是一個比較棘手的課題。我的下個目標就是要好好設計它,也許OSIV是個不錯的選擇:-)
          posted on 2009-06-04 12:20 Atea 閱讀(625) 評論(0)  編輯  收藏 所屬分類: GAE
          主站蜘蛛池模板: 车险| 吴江市| 大兴区| 渭源县| 韶山市| 邵阳市| 宁强县| 宝丰县| 大英县| 紫阳县| 海盐县| 瓮安县| 阿克苏市| 金山区| 邛崃市| 林周县| 扶沟县| 唐海县| 景宁| 易门县| 修武县| 遂宁市| 永新县| 乡宁县| 那曲县| 鄂伦春自治旗| 安义县| 晋城| 咸宁市| 南召县| 游戏| 全州县| 凤翔县| 麦盖提县| 桐乡市| 建阳市| 海口市| 荥经县| 鹿泉市| 三原县| 封丘县|