Google的GAE推出支持java的SDK后,本人就在第一时间下载并尝试运行demo,很成功; 不过在上周末尝试在自己的windows PC上上传app时遇到这样的问题:
1 在本机运行该app后,会在项目目录war\WEB-INF下生成一个叫appengine-generated的目录,里面保存的自然是index文件啦; 如果你的app不需要配置index,在上传时需要删除该文件夹,不然会报出类似下面的错误:
Reading application configuration data... 2009-04-13 12:06:55.354::INFO: Logging to STDERR via org.mortbay.log.StdErrLog 2009-4-13 12:06:56 com.google.apphosting.utils.config.AbstractConfigXmlReader getTopLevelNode 严重: Received IOException parsing the input stream for myapps/nodexy-v1/war\WEB-INF/datastore-indexes.xml com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanData(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanComment(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanComment(Unknown Source)
2 删除后再上传,又报出类似下面的错误:
Reading application configuration data... 2009-04-13 12:08:16.481::INFO: Logging to STDERR via org.mortbay.log.StdErrLog Beginning server interaction for nodexy... 0% Creating staging directory 5% Scanning for jsp files. 8% Compiling jsp files. 2009-4-13 12:08:18 org.apache.jasper.JspC processFile 信息: Built File: \guestbook.jsp 11% Compiling java files. java.lang.IllegalStateException: cannot find javac executable based on java.home, tried "D:\Program Files\Jav javac.exe" and "D:\Program Files\Java\bin\javac.exe" Unable to upload app: cannot find javac executable based on java.home, tried "D:\Program Files\Java\jre6\bin\ and "D:\Program Files\Java\bin\javac.exe"
上述错误的本质原因并不是你的JDK有问题,而是由于编码的原因! 因为下载的GAE JAVA SDK涉及到的编码问题。 一般情况下windows的默认编码都为GBK之类,而*nix都是utf-8之类。 google当然也是需要utf-8才好的;所以报错中的javac 其实很可能是由于编译时需要加 -encoding 参数而已!
问题描述大概如此!!! 以下是对解决方案的一点建议:
1 最直接高效的办法,转移到Linux下做开发;暂时不用windows; 在虚拟化如此流行的今天,同时拥有多个OS环境已经是件信手拈来的事了;比如SUN的V-BOX
2 参考博客: “Windows下编写google app engine jsp出现中文乱码问题的真正原因 ” 该文对GAE JSP乱码有一点分析,提供了一点解决办法,如果你觉得自己确实急切需要,可参考
3 等待GAE-Java-SDK下一个版本的更新吧!
PS: 我第一次上传成功的app: http://nodexy.appspot.com
GOOD LUCK !