天天看點

Google App Engine錯誤解決方案之Class com.xxx.xxx does not seem to have been enhanced. You may want to rerun the enhancer and check for

注:轉載請注明來源  zhuhuazha.

Google App Engine是廣大開發者們都試用過或者想試用的開發與部署平台。近日,平時用得好好的app engine竟然首頁打開就報錯: 

<stderr>: javax.jdo.JDOUserException: Persistent class "Class com.xxx.xxx does not seem to have been enhanced.  You may want to rerun the enhancer and check for errors in the output." has no table in the database, but the operation requires it. Please check the specification of the MetaData for this class.      

錯誤當中 xxxx指的是自定義的某JDO類。首頁使用JSP編寫,有datastore查詢過程,一直都挺好的,怎麼會突然出錯呢?

原因就在于錯誤裡面提示的。提示可以看出,問題與該使用JDO的類有關系,該類沒有得到“增強”enhance。在網上搜尋一遍之後,Google App Engine有jar包會對使用jdo的類會有個增強的步驟,這一點在App Engine的Using JDO with App Engine文章裡面Enhancing Data Classes節也有說明,該步驟對于使用Google Plugin for Eclipse使用者來說是透明的,它幫我們自動完成了。也可由指令行自行編譯

java -cp classpath com.google.appengine.tools.enhancer.Enhance class-files      

從指令中可以看出,它使用了SDK中appengine-tools-api.jar包。現在看來,報錯問題與此包或者該步驟有關,可能就是沒有做此步驟。

解決方法:在Eclipse當中為項目的Java Build Path 先去掉App Engine SDK,  再Clean掉項目的編譯内容,重新在Java Build Path中加入SDK,再重新編譯,再部署到Google, 問題解決。

(*注:問題出現多是Eclipse無故退出,重新啟動後并部署新的程式到App engine之後出現,是以很有可能是編譯設定上出的問題。)