1. 程式人生 > >Tomcat啟動失敗問題解決

Tomcat啟動失敗問題解決

fun could not web.xml ref ack pcl -a 重新 following

1. 系統框架加載正常,但是Tomcat啟動失敗,報錯如下:

Log代碼 技術分享圖片
  1. 2013-7-26 17:18:33 org.apache.catalina.core.StandardContext startInternal
  2. 嚴重: Error listenerStart
  3. 2013-7-26 17:18:34 org.apache.catalina.util.SessionIdGenerator createSecureRandom
  4. 信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [452
    ] milliseconds.
  5. 2013-7-26 17:18:34 org.apache.catalina.core.StandardContext startInternal
  6. 嚴重: Context [] startup failed due to previous errors
  7. 2013-7-26 17:18:34 org.apache.coyote.AbstractProtocol start
  8. 信息: Starting ProtocolHandler ["http-apr-8080"]
  9. 2013-7-26 17:18:34 org.apache.coyote.AbstractProtocol start
  10. 信息: Starting ProtocolHandler ["ajp-apr-8009"]
  11. 2013-7-26 17:18:34 org.apache.catalina.startup.Catalina start
  12. 信息: Server startup in 9576 ms
  13. diamond client log path : /home/admin/xxx/target/../logs/xx-client.log
  14. 2013-7-26 17:18:57 org.apache.catalina.loader.WebappClassLoader loadClass
  15. 信息: Illegal access: this web application instance has been stopped already. Could not load javax.xml.parsers.ParserConfigurationException. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
  16. java.lang.IllegalStateException
  17. at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1587)
  18. at com.taobao.tomcat.classloader.TomcatWebAppClassLoader.loadClass(TomcatWebAppClassLoader.java:37)
  19. at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
  20. at com.taobao.hsf.container.HSFClassLoaderDelegateHook.postFindClass(HSFClassLoaderDelegateHook.java:96)
  21. at org.eclipse.osgi.framework.internal.core.BundleLoader.searchHooks(BundleLoader.java:495)
  22. at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:461)
  23. at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:397)
  24. at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:385)
  25. at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)

2. 分析

查看上述日誌,可能會很明顯的看到下面很多的exception。都是this web application instance has been stopped already以及Could not load XX Class。但是不要被這些異常迷惑,他們只是結果而不是原因。

1). 細致一點可以查看到,哪些日誌是Tomcat是啟動完成之後報錯的。Server startup in 9576 ms

2). Tomcat日誌中有:嚴重: Error listenerStart。

3). 除了Error listenerStart沒有詳細日誌,但是可以知道是web.xml中listener初始化的時候出錯了。

3. 處理

1). 在WEB-INF/classes目錄下新建logging.properties

Log4j代碼 技術分享圖片
  1. handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
  2. ############################################################
  3. # Handler specific properties.
  4. # Describes specific configuration info for Handlers.
  5. ############################################################
  6. org.apache.juli.FileHandler.level = FINE
  7. org.apache.juli.FileHandler.directory = ${應用目錄}/logs
  8. org.apache.juli.FileHandler.prefix = error-debug.
  9. java.util.logging.ConsoleHandler.level = FINE
  10. java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

2). 重新啟動應用,指定目錄下會有一個error-debug.2013-07-07.log的錯誤日誌,或者錯誤日誌生成在jboss_stdout.log中。(日誌在Error listenerStart 到 Server startup in 9576 ms之間)

4. 結果

Tomcat log代碼 技術分享圖片
  1. 2013-7-29 9:58:11 org.apache.catalina.core.ApplicationContext log
  2. 信息: Initializing Spring root WebApplicationContext
  3. 2013-7-29 9:58:16 org.apache.catalina.core.StandardContext listenerStart
  4. 嚴重: Exception sending context initialized event to listener instance of class com.alibaba.citrus.webx.context.WebxContextLoaderListener
  5. org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:web/common/uris.xml]
  6. Offending resource: ServletContext resource [/WEB-INF/webx.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [web/common/uris.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionAttributes(Lorg/w3c/dom/Element;Ljava/lang/String;Lorg/springframework/beans/factory/config/BeanDefinition;Lorg/springframework/beans/factory/support/AbstractBeanDefinition;)Lorg/springframework/beans/factory/support/AbstractBeanDefinition;
  7. Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [web/common/uris.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionAttributes(Lorg/w3c/dom/Element;Ljava/lang/String;Lorg/springframework/beans/factory/config/BeanDefinition;Lorg/springframework/beans/factory/support/AbstractBeanDefinition;)Lorg/springframework/beans/factory/support/AbstractBeanDefinition;
  8. Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionAttributes(Lorg/w3c/dom/Element;Ljava/lang/String;Lorg/springframework/beans/factory/config/BeanDefinition;Lorg/springframework/beans/factory/support/AbstractBeanDefinition;)Lorg/springframework/beans/factory/support/AbstractBeanDefinition;
  9. at com.alibaba.citrus.springext.util.SpringExtUtil.parseBeanDefinitionAttributes(SpringExtUtil.java:223)
  10. at com.alibaba.citrus.service.uribroker.impl.URIBrokerServiceDefinitionParser.doParse(URIBrokerServiceDefinitionParser.java:48)
  11. at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:81)
  12. at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:56)
  13. at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
  14. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1123)
  15. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1113)
  16. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
  17. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
  18. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:468)
  19. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:363)

5. 看到上述日誌,問題就很容易解決了,明顯是由於spring的類沖突導致,分析之後發現,是由於spring-2.0.7與spring-2.5.6的類沖突導致。

6. 如果上述不行,可以嘗試:

http://www.havenliu.com/web/298.html

http://grails.1312388.n4.nabble.com/Deployment-problems-td4628710.html

http://xpenxpen.iteye.com/blog/1545648

Tomcat啟動失敗問題解決