尝试获取sun-web-app_2_5时Glassfish中的连接超时
问题描述:
尝试在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");
答
我会建议你使用admin console to tune the JVM settings来include the appropriate properties that define the JVM's proxied environment。
这里是你需要使用控制台页面的截图...
这将使服务器获取到丢失的DTD文件,而无需扰乱整体您的开发人员机器的系统配置。