天天看點

tomcat 報“INFO deploying web application directory......” 解決方案

安裝完畢tomcat,啟動後總是卡住在“INFO deploying web application directory......”,浏覽器通路8080端口,通路不到。修改成其他端口後,啟動還是會卡很久,但是浏覽器通路新配置的端口,就可以通路到。

如圖:

此方案,借鑒網上的内容:

securerandom.source=file:/dev/./urandom

這時候根據修改内容就可以查到因為此原因不僅可以造成tomcat卡住,也會造成weblogic啟動緩慢,

linux或者部分unix系統提供随機數裝置是/dev/random 和/dev/urandom ,兩個有差別,urandom安全性沒有random高,但random需要時間間隔生成随機數。jdk預設調用random。

再後來,終于在weblogic的官方文檔中 Monitoring and Troubleshooting 找到了 Avoiding JVM Delays Caused By Random Number Generation 這樣一個标題。摘錄如下:

To determine if your operating system exhibits this behavior, try displaying a portion of the file from a shell prompt:

head -n 1 /dev/random

Open the $JAVA_HOME/jre/lib/security/java.security file in a text editor.

Change the line:

securerandom.source=file:/dev/random

to read:

securerandom.source=file:/dev/urandom

Save your change and exit the text editor.

其中說到:可通過 head -n 1 /devrandom 檢視是否你的系統會出現僞随機數提供等待。OK就這個,試了一下,果然,在伺服器第一次啟動後,這個可以快速提供一個值,但當再次調用時發生等待。

解決辦法:

永久:oracle 說修改 $JAVA_HOME/jre/lib/security/java.security 檔案,替換securerandom.source=file:/dev/random 為 securerandom.source=file:/dev/urandom。對所有使用JVM的應用生效。(這個永久的方法,這裡面有個問題,就是設定時候實際應該設定為securerandom.source=file:/dev/./urandom,否則不生效)

DOMAIN臨時:修改startWeblogic.sh檔案,JAVA_OPTIONS="${SAVE_JAVA_OPTIONS} -Djava.security.egd=file:/dev/./urandom"

後繼的SecureRandom 測試學習

編寫JAVA類如下,運作測試,第一次正常,第二次等待,重新開機伺服器後第一次又正常。啟動加入參數 -Djava.security.egd=file:/dev/./urandom 正常

本文轉自 kesungang 51CTO部落格,原文連結:http://blog.51cto.com/sgk2011/1899720,如需轉載請自行聯系原作者