3分ごとにXMLファイルをプルし、XMLを解析した後、ハッシュテーブルを最新の状態に保つ必要があるGWTアプリケーションのサーバー側コンポーネントを作成しようとしています。
調査の結果、ScheduledThreadPoolExecutorを使用してスレッドを設定しました
stationParser = new TFLStationsParserThread(bikeStations);
scheduler.scheduleWithFixedDelay(stationParser, 2, 180, SECONDS);
TFLStationsParserThreadには最小限のコンストラクターがあり、このrun()メソッドは
public void run() {
System.out.println("TFLStationsParserThread run()");
stationParser.refreshStationData(stations);
}
stationParserは、最終的に次のコマンドでデータを取得します
HTTPResponse response = URLFetchServiceFactory.getURLFetchService().fetch(request);
これが私の問題です:これ.fetch()
をScheduledThreadPoolExecutor内から実行すると、次のエラーが発生します
com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' was not found.
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:98)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:37)
at couk.mtaylor.bikes.server.TFLStationsParser.refreshStationData(TFLStationsParser.java:66)
at couk.mtaylor.bikes.server.TFLStationsParserThread.run(TFLStationsParserThread.java:35)
...
scheduleWithFixedDelay
スケジューラーをコメントアウトしてrefreshStationData
直接呼び出すと、そのような問題は発生しません。
これにより、スレッドに必要なGWTライブラリがいくつか欠落していると思いますが、これは私の知識を超えており、役立つソリューションをオンラインで見つけることができません。
メソッドを直接呼び出したときに、スケジュールされたスレッド内からこれらのGWTエラーメッセージが表示されるのはなぜですか?