bco 发表于 2018-11-29 11:59:35

记录一次tomcat排错过程

  现象环境描述:测试环境,一直在运行跨易达系统(业务系统),研发重新发了个war包,就访问不了了,提交到运维这边说是环境问题,于是我开始排查。
  

  1、JAVA_HOME、CATALINA_HOME检查
  # echo $JAVA_HOME
  /usr/local/jdk1.7.0_60
  2、检查server.xml
  
  
  检查修改后的网站根目录,没有问题
  浏览器访问提示,网页不存在
http://s5.运维网.com/wyfs02/M02/80/71/wKioL1dCYdiwCMefAABPnaaJjpA960.png
  curl提示404
http://s3.运维网.com/wyfs02/M01/80/71/wKioL1dCY3bDdKOJAAAZrvGSVOg118.png
  很奇怪,程序代码明明放在根目录里面,怎么会找不到呢!
  3、查看日志
  tail -f catalina.out,重新启动tomcat,提示日志错误如下:
http://s5.运维网.com/wyfs02/M02/80/71/wKioL1dCZyPDKndEAACV61JXgkQ138.png里面有些错误和警告,主要是:
  十一月 23, 2013 7:21:58 下午 org.apache.catalina.core.StandardContext startInternal
  SERVER: Error filterStart
  十一月 23, 2013 7:21:58 下午 org.apache.catalina.core.StandardContext startInternal
  SERVER: Context startup failed due to previous errors
  4、分析原因,解决方法
  分析:Tomcat后台信息太少以至于不能得出问题空间出在哪儿(Tomcat的日志目录也无相关信息)通过配置Tomcat的Log,让它记录更多的日志信息,方能进一步分析原因。在不能启动的Web应用目录(我这里是greenpass)下WEB-INF/classes目录中,新建logging.properties文件,内容参考如下
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler  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.log2016-05-23.log,如下图:
http://s5.运维网.com/wyfs02/M02/80/73/wKiom1dCaCyyyV0BAAAmsc4hB1c586.png
  more error-debug.log2016-05-23.log,发现一个错误提示信息:
  SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSourceJdbc' defined in file : Could not resolve placeholder 'db1.driver' in string value
  "${db1.driver}"
  发现是web根目录的spring-datasource.xml里面的db1.driver没有定义,跟开发说了这个问题以后,注释掉这部分代码就能够正常访问了。
  

  备注:server.xml里面有关于logs配置的信息,如下:
  
  默认是开启的,每天会生成一个单独的日志,例如:localhost.2016-05-22.log,我的这一块的配置不知出于什么原因被注销了,不然也不会费这么长时间了。



页: [1]
查看完整版本: 记录一次tomcat排错过程