【Tomcat】Tomcat報錯追蹤

應用部署上之後無法正常啓動,tomcat啓動日誌如下:

信息: Starting service Catalina

2015-7-22 18:39:31 org.apache.catalina.core.StandardEngine start

信息: Starting Servlet Engine: Apache Tomcat/6.0.36

2015-7-22 18:39:31 org.apache.catalina.startup.HostConfig deployDirectory

信息: Deploying web application directory cdr

2015-7-22 18:39:31 org.apache.catalina.loader.WebappClassLoader validateJarFile

信息: validateJarFile(/cdr/webserver/CDR2.0/webapps/cdr/WEB-INF/lib/javaee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

2015-7-22 18:39:34 org.apache.catalina.core.StandardContext start

嚴重: Error listenerStart

2015-7-22 18:39:34 org.apache.catalina.core.StandardContext start

嚴重: Context [/cdr] startup failed due to previous errors

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

嚴重: The web application [/cdr] registered the JDBC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

嚴重: The web application [/cdr] 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.

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [FileWatchdog] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-5] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-1] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-2] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-3] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 18:39:34 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-4] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 18:39:34 org.apache.coyote.http11.Http11Protocol start

信息: Starting Coyote HTTP/1.1 on http-8080

2015-7-22 18:39:34 org.apache.jk.common.ChannelSocket init

信息: JK: ajp13 listening on /0.0.0.0:9090

2015-7-22 18:39:34 org.apache.jk.server.JkMain start

信息: Jk running ID=0 time=0/11  config=null

2015-7-22 18:39:34 org.apache.catalina.startup.Catalina start

信息: Server startup in 3280 ms

開始以爲是jar包衝突,刪除javaee.jar包解決了jar包衝突問題,啓動依然報錯,日誌信息如下:

2015-7-22 19:34:23 org.apache.catalina.core.StandardService start

信息: Starting service Catalina

2015-7-22 19:34:23 org.apache.catalina.core.StandardEngine start

信息: Starting Servlet Engine: Apache Tomcat/6.0.36

2015-7-22 19:34:23 org.apache.catalina.startup.HostConfig deployDirectory

信息: Deploying web application directory cdr

2015-7-22 19:34:25 org.apache.catalina.core.StandardContext start

嚴重: Error listenerStart

2015-7-22 19:34:25 org.apache.catalina.core.StandardContext start

嚴重: Context [/cdr] startup failed due to previous errors

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

嚴重: The web application [/cdr] registered the JDBC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

嚴重: The web application [/cdr] 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.

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [FileWatchdog] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-5] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-1] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-2] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-3] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 19:34:25 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

嚴重: The web application [/cdr] appears to have started a thread named [Thread-4] but has failed to stop it. This is very likely to create a memory leak.

2015-7-22 19:34:25 org.apache.coyote.http11.Http11Protocol start

信息: Starting Coyote HTTP/1.1 on http-8080

2015-7-22 19:34:25 org.apache.jk.common.ChannelSocket init

信息: JK: ajp13 listening on /0.0.0.0:9090

2015-7-22 19:34:25 org.apache.jk.server.JkMain start

信息: Jk running ID=0 time=0/10  config=null

2015-7-22 19:34:25 org.apache.catalina.startup.Catalina start

信息: Server startup in 2639 ms

這時候報錯只能看到和JDBC有一些關係,報錯不明顯。

通過以下設置可以設置對於Tomcat的追蹤,生成更爲詳細的錯誤報告:

WEB-INF/classes目錄下新建一個文件叫logging.properties,內容如下:

handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler   

  

############################################################   

# Handler specific properties.   

# Describes specific configuration info for Handlers.   

############################################################   

  

org.apache.juli.FileHandler.level = FINE   

org.apache.juli.FileHandler.directory = ${catalina.base}/logs   

org.apache.juli.FileHandler.prefix = error-debug.   

  

java.util.logging.ConsoleHandler.level = FINE   

java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter  

 

這樣,我們再啓動tomcat時,就會在logs目錄下生成一個更詳細的日誌error-debug.**.log

,並且詳細報錯也會在應用的日誌中輸出出來,通過該種設置,可以看到的詳細錯誤如下:

......

### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'cdr.gg_alarm_contact_r' doesn't exist

### The error may involve defaultParameterMap

### The error occurred while setting parameters

### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'cdr.gg_alarm_contact_r' doesn't exist

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'cdr.gg_alarm_contact_r' doesn't exist

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

......

可以看到真正導致Tomcat無法啓動的原因是由於數據庫中缺乏表cdr.gg_alarm_contact_r,重新創建該表後應用啓動正常。

 

 

總結:

Tomcat本身啓動的報錯可能都比較含糊,可能只提示了Error listenerStart。爲了調試,我們要獲得更詳細的日誌,這時候就可以通過這種方法進行設置,從而更有效的追蹤具體的報錯。

 

 

 

發佈了86 篇原創文章 · 獲贊 11 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章