1. 程式人生 > >測試伺服器上直接修改properties檔案導致OOM的問題

測試伺服器上直接修改properties檔案導致OOM的問題

場景:測試伺服器上,在未停止tomcat的情況下直接修改了配置檔案(properties檔案),稍後再有請求進來時(該請求會使用到properties檔案中的屬性),引發了OOM

tomcat7.0.50配置檔案:
	conf/server.xml中:
		<Context docBase="advertise-war" path="/advertise-war" reloadable="true" />
		path:		訪問該Web應用的URL入口
		reloadable:tomcat在執行時會監控 WEB-INF/classes 和 WEB-INF/lib目錄下的class檔案,如果監測到有class檔案被更新的,tomcat會自動重新載入(先解除安裝,再部署)Web應用。

分析:
	1)在解除安裝的過程中,(大概是由於檔案被修改後)程式可能出錯,導致原來的web應用解除安裝失敗,從而導致原來的web應用仍然存在於Tomcat的快取之中。
	2)雖然解除安裝失敗,但是tomcat仍然會部署修改後的web應用。
	3)從而導致:tomcat在重新部署web應用時,由於無法刪除已有的快取,故可能會出現記憶體溢位的異常。
	
建議:
	1)將reloadable屬性設為false。
	2)將需要經常修改的配置檔案(properties檔案等)的配置資訊持久化到資料庫中。
		即:獲取配置資訊的策略由 配置檔案的形式 改為 從資料庫中獲取(如果頻繁使用,則放到快取中)。
		
		
		
之後進行本地測試時,部分日誌的擷取:


注:雖然沒有報OOM,但是從日誌可以推斷出:如果重啟前,正在執行的執行緒比較多的話,則在重啟的過程中很可能報OOM。


 7:39:42 下午 org.apache.catalina.core.StandardContext reload
資訊: Reloading Context with name [/landpage-***-war] has started
 7:39:42 下午 org.apache.catalina.core.StandardWrapper unload
資訊: Waiting for 1 instance(s) to be deallocated for Servlet [advertise-landpage]
 7:39:43 下午 org.apache.catalina.core.ApplicationContext log
資訊: Destroying Spring FrameworkServlet 'advertise-landpage'
 7:39:43 下午 org.apache.catalina.core.ApplicationContext log
資訊: Closing Spring root WebApplicationContext
 7:39:43 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
警告: The web application [landpage-***-war] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
 7:39:43 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
警告: The web application [landpage-***-war] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(Unknown Source)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
 7:39:43 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
警告: The web application [landpage-***-war] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Unknown Source)
java.util.TimerThread.run(Unknown Source)
 7:39:43 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
警告: The web application [landpage-***-war] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Unknown Source)
java.util.TimerThread.mainLoop(Unknown Source)
java.util.TimerThread.run(Unknown Source)
 7:39:43 下午 org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
嚴重: The web application [landpage-***-war] created a ThreadLocal with key of type [org.springframework.core.NamedThreadLocal] (value [Locale context]) and a value of type [org.springframework.context.i18n.SimpleLocaleContext] (value [zh_CN]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
 7:39:43 下午 org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
嚴重: The web application [landpage-***-war] created a ThreadLocal with key of type [org.springframework.core.NamedThreadLocal] (value [Request attributes]) and a value of type [org.springframework.web.context.request.ServletRequestAttributes] (value [o[email protected]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
 7:39:46 下午 org.apache.jasper.servlet.TldScanner scanJars
資訊: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
 7:39:46 下午 org.apache.catalina.core.ApplicationContext log
資訊: No Spring WebApplicationInitializer types detected on classpath

 7:39:46 下午 org.apache.catalina.core.ApplicationContext log
資訊: Initializing Spring root WebApplicationContext

 7:39:49 下午 org.apache.catalina.core.ApplicationContext log
資訊: Initializing Spring FrameworkServlet 'advertise-landpage'

 7:39:50 下午 org.apache.catalina.core.StandardContext reload
資訊: Reloading Context with name [/landpage-***-war] is completed




相關推薦

測試伺服器直接修改properties檔案導致OOM的問題

場景:測試伺服器上,在未停止tomcat的情況下直接修改了配置檔案(properties檔案),稍後再有請求進來時(該請求會使用到properties檔案中的屬性),引發了OOM tomcat7.0.50配置檔案: conf/server.xml中: <Con

linux---修改.bashrc檔案導致終端命令不能使用

其實解決問題的方法很簡單:把你在bashrc檔案中寫錯的東西註釋掉或者改寫正確即可。 可是此時圖形介面登陸不了,vim用不了。怎麼改? 解決方案:      步驟1:輸入命令export PATH=/bin:/usr/local/sbin:

基於Tomcat如何顯示伺服器的圖片或檔案

修改tomcat中conf資料夾下的server.xml檔案,在 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"           

在開始準備測試環境前,都需要看測試伺服器的那些資訊?

查詢伺服器版本 lsb_release -a 結果 LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-

Eclipse修改properties檔案預設編碼

無論工作空間的編碼設定的是什麼,Eclipse中檔案properties預設編碼都為ios-5529-1,我們在裡面輸入中文會自動轉碼: #\u6D4B\u8BD5 1 以上內容毫無閱讀性可言,為了解決這個問題,可以修改Eclipse的全域性配置,把Properties檔

專案執行過程中修改.properties檔案問題

專案執行過程中需要修改配置檔案的程式碼。菜鳥貼出記錄自己成長。。 /** showOu 要修改為的值    */ public void setAttribute(String value) {         OutputStream out = null;       

linux伺服器下載的csv檔案在window環境下用excel開啟的亂碼問題解決

【問題產生原因】 Excel預設並不是以UTF-8來開啟檔案,所以在csv開頭加入BOM,告訴Excel檔案使用utf-8的編碼方式。 【核心程式碼】 response.setContentType

java專案中,關於svn同步了setting檔案 導致本地資料夾錯亂的問題的解決

那天也不造那個同仁把setting檔案提交了,搞得我一天沒有好好工作. 說說我的解決方法吧: 1:將本地的.settings資料夾,.classpath,.project檔案刪除; 2.將別的專案的 .classpath,.project考到本專案; 3.此時的web專案就

11g rac 修改引數檔案導致資料庫無法啟動 解決方案!

rac中spfile預設是存在  '+DATADG/SID/spfileSID.ora' 然而一次修改錯誤的修改引數,重啟起資料庫之後報錯導致資料庫起不來了。 則可以先用各個節點上備用的pfile來啟動。備用pfile位置:        '$ORACLE_BASE/adm

JMeter建立FTP測試伺服器傳下載效能

在工作中,有時候我們會對伺服器的上傳下載效能進行測試,於是就整理了工作中測試ftp上傳下載的是實戰總結。測試環境:jmeter 我使用的是apache-jmeter-2.13測試伺服器是阿里雲上的真實伺服器,IP:***.***.***.*** (為了伺服器安全,我就不寫那麼

java 讀取,修改properties檔案,不改變檔案內容順序

FileInputStream input1 = new FileInputStream("/jdbc.properties");//讀取程式碼 SafeProperties safeProp1 = new SafeProperties();

javaWeb向伺服器傳和下載檔案

專案經常需要向伺服器上傳檔案或者從伺服器下載檔案,因此將所需要的許多方法整理到了一個工具類中,包括從伺服器下載流檔案,上傳檔案到伺服器(用Apache和spring不同的方法),希望能幫助到大家。package com.phy.szms.utils; import java

關於JAVA中怎麼讀取和修改.properties檔案中的值

第一種方式: 以我自己的專案為原型這裡案例一個最簡單的獲取方法 定義一個獲取類 package com.boli.tianchuang.sys.util; import java.io.*; import java.util.Properties; /** * De

maven 根據P引數值打包動態修改properties檔案中值或一定properties

由於本人 最近忙著公司事情,昨天沒有寫部落格,今天就繼續寫吧 需求:由於最近開發clover專案 ,沒有使用spring,更沒有使用任何框架,而使用J2EE的web工程,所以連線ZK和MongoDB、Redis等伺服器需用指定properties檔案, 而目前公司又分各套環

C# WinForm 通過URL取得伺服器的某圖片檔案到本地

方法1示例程式碼: -------------- string strImageURL = "http://192.168.0.1:88/VDirA/images/1.jpg"; System.Net.WebClient webClient = new System.N

本地的專案部署到伺服器修改的部分

部署需修改的地方注意:首先要關閉tomcat一、資料庫連線二、圖片上傳配置檔案,工具類圖片顯示配置檔案,工具類server中與配置檔案一致server.xml中<Context docBase="D:\upload\pic" path="pic"/>三、uedit

使用AJAX方法可以不重新整理頁面就從伺服器獲得資訊(檔案資訊,方法,資料庫中的資料)

C6.1 傳送請求                                                                                                               說明 $.ajax([url],o

伺服器自己新建sh檔案執行Permission denied的解決辦法

最近在研究caffe的時候,遇到了一個問題坑了好久。寫了一個caffe測試已有模型的精度的sh檔案。 問題 sh檔案的內容如下: ./build/tools/caffe --help ##執行caffe的測試功能 生成之後執行這個sh檔案出錯

通過http請求tomcat服務直接下載linux伺服器檔案

如圖所示,在linux伺服器上有如圖一些檔案,現在想通過http訪問tomcat的請求方式來獲取這些檔案 步驟: 1、找到伺服器上tomcat的server.xml的檔案,新增一句: <Context docBase ="/usr/local/download/" path ="/

記錄一下:傳到伺服器的pdf 檔案直接下載而非在瀏覽器裡開啟

原文地址:https://segmentfault.com/q/1010000000692593/a-1020000000692707 這邊自己記錄一下 點選 <a href="Test.pdf">下載</a> 的時候,Chrome 會自動呼叫內建