Android+appengine アプリケーション (エンドポイント) を起動して実行し、すべてがローカル マシンで正常に動作するようになったので、appengine コードをアップロードして、Android アプリケーションを介して携帯電話で直接データにアクセスできるようにすることにしました。
appengine バックエンドを呼び出そうとすると、404 エラーが発生しました。
ブラウザーで http://[myAppID].appspot.com/_ah/spi を呼び出そうとすると、次のようになります。
Error: HTTP method GET is not supported by this URL
メインのサーベットが応答していますが、何が間違っていますか??
(インターネットの許可が与えられました!)
前もって感謝します!!
コードは次のとおりです。これは AsyncTask 内で実行されます。
Builder endpointBuilder = new Myendpoint.Builder(AndroidHttp.newCompatibleTransport(), new JacksonFactory(), new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) {
}
});
Myendpoint endpoint = CloudEndpointUtils.updateBuilder(endpointBuilder).build();
try {
MyUsers result = endpoint.searchMyUser(params[0]).execute();
return result.getItems().get(0);
} catch (Exception e) {
e.printStackTrace();
return null;
}
これは CloudEnpointUtils 内のコードです (明らかに、LOCAL_ANDROID_RUN は false に設定されています)。
public static <B extends GoogleClient.Builder> B updateBuilder(B builder) {
if (LOCAL_ANDROID_RUN) {
builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/");
}
// only enable GZip when connecting to remote server
final boolean enableGZip = builder.getRootUrl().startsWith("https:");
builder.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
public void initialize(JsonHttpRequest jsonHttpRequest) {
jsonHttpRequest.setEnableGZipContent(enableGZip);
}
});
return builder;
}
エラーの logcat を追加します。
10-04 11:40:22.770 W/System.err(13564): com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
10-04 11:40:22.770 W/System.err(13564): Not Found
10-04 11:40:22.775 W/System.err(13564): at com.google.api.client.googleapis.services.GoogleClient.executeUnparsed(GoogleClient.java:279)
10-04 11:40:22.775 W/System.err(13564): at com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:207)
10-04 11:40:22.775 W/System.err(13564): at com.appspot.api.services.myuserendpoint.Myuserendpoint$SearchMyUser.execute(Myuserendpoint.java:702)
10-04 11:40:22.775 W/System.err(13564): at it.my.my.app.core.MyBusinessDelegate$MyUserGetter.doInBackground(MyBusinessDelegate.java:303)
10-04 11:40:22.775 W/System.err(13564): at it.my.my.app.core.MyBusinessDelegate$MyUserGetter.doInBackground(MyBusinessDelegate.java:1)
10-04 11:40:22.780 W/System.err(13564): at android.os.AsyncTask$2.call(AsyncTask.java:264)
10-04 11:40:22.780 W/System.err(13564): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-04 11:40:22.780 W/System.err(13564): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-04 11:40:22.780 W/System.err(13564): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
10-04 11:40:22.785 W/System.err(13564): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-04 11:40:22.785 W/System.err(13564): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-04 11:40:22.785 W/System.err(13564): at java.lang.Thread.run(Thread.java:856)
編集: AppEngine DeployLog
------------ Deploying frontend ------------
Preparing to deploy:
Created staging directory at: 'C:\Users\XXXXXXXXX\AppData\Local\Temp\appcfg1884750854541661749.tmp'
Scanning for jsp files.
Compiling jsp files.
Scanning files on local disk.
Initiating update.
Cloning 1 static files.
Cloning 66 application files.
Deploying:
Uploading 0 files.
Initializing precompilation...
Deploying new version.
Verifying availability:
Will check again in 1 seconds.
Will check again in 2 seconds.
Will check again in 4 seconds.
Closing update: new version is ready to start serving.
Updating datastore:
Uploading index definitions.
Deployment completed successfully
EDIT2:その他の情報
appengine war に入れた Java サーブレットと通信しようとしましたが、ブラウザ経由で問題はありません。コマンド ラインから ping を実行するか、プログラムで通信しようとすると、次のエラーが発生します。
"Unable to resolve host "[myappID].appspot.com": No address associated with hostname"
誰かが解決策を見つけるのを手伝ってください
編集 3: 良いニュースです。次のバージョンの appengine アドレスを使用してサーブレットを呼び出すことができました。
http://[version].[myAppID].appspot.com/myServlet
それ以外の:
http://[myAppID].appspot.com/myServlet
理由はわかりませんが、このように機能します。version-address トリックを使用しても、エンドポイント経由でリモート appengine アプリを呼び出そうとしてもうまくいきません。これが役立つことを願っています!