嘗試在liferay門戶上部署glassfish v2應用服務器上的war文件時出現問題。當我們從Ubuntu 10.4升級到10.10(或更高)時,我們的部署時間從21秒左右到6分鐘。我看起來問題是當試圖從oracle獲得http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd時發生超時。在這些發行版之間,有些事情必須在Ubuntu上進行更改。我想問題的一部分是,我們背後的公司防火牆/代理,但不會改變我害怕..嘗試獲取sun-web-app_2_5時Glassfish中的連接超時
那麼什麼是最好的。將sun.net.client.defaultConnectTimeout設置爲21秒(工作並給出與10.4相同的部署時間),將dtd本地存儲以便訪問(因爲現在我們無法從10.4或10.10訪問它,因此時間-out)。我想我們可以在我們的開發人員機器上改變Linux的tcp設置,但這似乎不是一個好的解決方案。
使用下面的代碼,我們得到了10.10的約10.4秒和約10.10秒的189秒的超時。
long start = System.currentTimeMillis();
try {
System.out.println("start");
URL u = new URL("http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd");
URLConnection conn;
conn = u.openConnection();
System.out.print(conn.getConnectTimeout());
//conn.setConnectTimeout(5*1000);
int readTimeout = conn.getReadTimeout();
BufferedReader in = new BufferedReader(
new InputStreamReader(
conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Total time = " + (System.currentTimeMillis() - start)/1000.0 + " seconds");