tomcat启动报错原因分析及解决


1.报错日志

拿到catalina.log的启动日志

2015-8-13 15:24:02 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2015-8-13 15:24:02 org.apache.catalina.core.StandardContext start
严重: Context [/callback] startup failed due to previous errors
2015-8-13 15:24:02 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/callback] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2015-8-13 15:24:02 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/callback] registered the JDBC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2015-8-13 15:24:02 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/callback] 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-8-13 15:24:02 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/callback] 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-8-13 15:24:02 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/callback] appears to have started a thread named [commons-pool-EvictionTimer] but has failed to stop it. This is very likely to create a memory leak.
2015-8-13 15:24:03 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2015-8-13 15:24:03 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8920
2015-8-13 15:24:03 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2015-8-13 15:24:03 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/18  config=null
2015-8-13 15:24:03 org.apache.catalina.startup.Catalina start
信息: Server startup in 48288 ms

刚开始分析,怀疑是数据库有异常

The web application [/callback] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

然后通过DBA分析,发现数据库所有的连接都是正常的,没有未释放的链接。然后立即转向,发现这样一句:

严重: Context [/callback] startup failed due to previous errors

不过这里没有发现报错日志,然后立即去查localhost.log,看到报错日志

2015-8-13 15:23:17 org.apache.catalina.core.ApplicationContext log
信息: Initializing Logback from [/u1pf_bgwghttp/tomcat_bgw/webapps/callback/WEB-INF/logback.xml]
2015-8-13 15:23:57 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending context initialized event to listener instance of class ch.qos.logback.ext.spring.web.LogbackConfigListenerjava.lang.RuntimeException: Unexpected error while configuring logback at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging(WebLogbackConfigurer.java:146)
 然后又看到: Caused by: java.net.UnknownHostException: www.w3.org 异常。  
  

然后打开logback.xml配置文件,看到如下配置:




	
	
		
			[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%logger{36}] - %msg%n
		
		
			INFO
			DEBUG
		
	
2.定位原因,解决问题

到这一步,基本定位到原因了,下一步,就要看下为啥报错了。spring解析logback.xml要访问

http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd

然后ping  www.w3.org  不通,怀疑是最近主机组做了网络限制。

这句配置,对于自定义xml文件来说,不是必须。所以,去掉这行配置。问题解决。

3.遗留疑问

3.1 为什么spring解析logback.xml要调用 http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd

答:待研究

3.2   http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd在这里到底做什么用?
答:DTD是一种保证XML文档格式正确的有效方法,可以比较XML文档和DTD文件来看文档是否符合规范,元素和标签使用是否正确。一个DTD文档包含:元素的定义规则,元素间关系的定义规则,元素可使用的属性,可使用的实体或符号规则。 


DTD分为内部DTD与外部DTD,内部DTD包含在XML文档中,外部DTD则通过URL引用.一个DTD文件是以.dtd结尾的文本文件 



 
  


你可能感兴趣的:(Java,开发)