應用部署上以後沒法正常啓動。tomcat啓動日誌例如如下:java
信息: Starting service Catalinamysql
2015-7-22 18:39:31 org.apache.catalina.core.StandardEngine startweb
信息: Starting Servlet Engine: Apache Tomcat/6.0.36spring
2015-7-22 18:39:31 org.apache.catalina.startup.HostConfig deployDirectorysql
信息: Deploying web application directory cdr數據庫
2015-7-22 18:39:31 org.apache.catalina.loader.WebappClassLoader validateJarFileapache
信息: 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.classtomcat
2015-7-22 18:39:34 org.apache.catalina.core.StandardContext startapp
嚴重: Error listenerStartwebapp
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。爲了調試,咱們要得到更具體的日誌。這時候就可以經過這樣的方法進行設置。從而更有效的追蹤具體的報錯。