Tomcat 报错: SEVERE: One or more listeners failed to start.

本文详细记录了一个在Spring项目中启动Tomcat时遇到的诡异bug,描述了从错误信息“SEVERE:One or more listeners failed to start”出发,如何定位问题到资源文件加载失败,并最终在resources目录下找到未正确加载的db-config.properties文件,通过调整文件位置至WEB-INF目录下解决了问题。

1. bug描述: 在写Spring代码的时候, 启动Tomcat时报错.
2. bug信息:

Connected to server
[2017-11-16 09:28:36,551] Artifact Spring_10:war exploded: Artifact is being deployed, please wait...
Nov 16, 2017 9:28:37 PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
INFO: validateJarFile(/home/dela/IdeaProjects/Spring/Spring_10/out/artifacts/Spring_10_war_exploded/WEB-INF/lib/javax.servlet-api-3.1.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Nov 16, 2017 9:28:38 PM org.apache.catalina.deploy.WebXml setVersion
WARNING: Unknown version string [3.1]. Default version will be used.
Nov 16, 2017 9:28:42 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Nov 16, 2017 9:28:42 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Nov 16, 2017 9:28:42 PM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Nov 16, 2017 9:28:43 PM org.apache.catalina.core.StandardContext startInternal
**SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file**
Nov 16, 2017 9:28:43 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
[2017-11-16 09:28:43,528] Artifact Spring_10:war exploded: Error during artifact deployment. See server log for details.


3. bug解决:
这个bug相当诡异啊, 它诡异在IDEA的报错信息只有一句话: SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file, 信息里面提示去查看错误日志, 但是IDEA下面的错误日志是空! 这就很尷尬, 因为仅凭这一句话, 没办法定位错误出在哪里.

(1) 找到错误日志
之前问过恒毅, 他说如果IDEA下面没有错误日志, 就去tomcat安装包下面的logs目录里面找, 但是然而并没有找到, 只有一些很久之前的错误日志.

后来才知道, 错误日志在/home/dela/.IntelliJIdea2017.1/system/tomcat/Unnamed_Spring_10(当前Project的名字)下, 也就是家目录下的.IntelliJIdea2017.1/system/tomcat, 然后找到本工程的tomcat名字, 进入logs目录就能看到当天的错误日志了.

我是在localhost.2017-11-16.log 中找到问题的原因的, 错误信息如下:

Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/classpath*:db-config.properties]
    at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
    at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:153)
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:80)
    ... 52 more


(2) 解决问题
原因是我的一个XML文件在载入properties配置文件时路径不对, 我把它放在了resources目录下(但是为什么放在resources目录下它会找不到现在还不清楚), 导致文件无法被加载, 将这个文件放入WEB-INF下, 通过/WEB-INF/db-config.properties就能访问加载到了!
--------------------- 
作者:dela_ 
来源:优快云 
原文:https://blog.youkuaiyun.com/dela_/article/details/78555977 
版权声明:本文为博主原创文章,转载请附上博文链接!

12-Jul-2023 18:36:28.896 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file 12-Jul-2023 18:36:28.898 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/setting] startup failed due to previous errors 2023-07-12 18:36:28,899 [// - - ] INFO org.springframework.web.context.support.XmlWebApplicationContext - Closing Root WebApplicationContext: startup date [Wed Jul 12 18:36:27 CST 2023]; root of context hierarchy 2023-07-12 18:36:28,900 [// - - ] INFO org.springframework.cache.ehcache.EhCacheManagerFactoryBean - Shutting down EhCache CacheManager 12-Jul-2023 18:36:28.908 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [setting] 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. 12-Jul-2023 18:36:28.908 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [setting] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143) com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
07-13
01-Jul-2025 18:26:22.896 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [/ecm-sf5-cn] startup failed due to previous errors 01-Jul-2025 18:26:22.968 WARNING [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ecm-sf5-cn] appears to have started a thread named [Catalina-utility-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:4825) org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1172) org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1176) org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1176) org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1154) java.base@17.0.12/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) java.base@17.0.12/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) java.base@17.0.12/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) java.base@17.0.12/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) java.base@17.0.12/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) java.base@17.0.12/java.lang.Thread.run(Thread.java:840) 01-Jul-2025 18:26:22.968 WARNING [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ecm-sf5-cn] appears to have started a thread named [DefaultQuartzScheduler_QuartzSchedulerThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.base@17.0.12/java.lang.Object.wait(Native Method) org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:427) 01-Jul-2025 18:26:22.977 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ecm-sf5-cn] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@3777677a]) and a value of type [com.documentum.web.env.app.AppServerEnvironment] (value [[Name = App Server Environment, Description = App Server Environment Implementation, Major Version = 0, Minor Version = 1, Author = Documentum, Portal Description = App Server, Portal Version = x.x, Environment Base Version = 1.0, Environment Service Version = 6.0, Supports Dispatch Contract = true, Supports Theme Contract = true, Supports Error Contract = true, Supports FormOperationListener Contract = false, Supports Locale Contract = true, Supports Session Contract = true, Supports Tag Contract = false, Supports Render Contract = true, Supports Login Contract = false, Supports Security Contract = true, Supports ActionPrecondition Contract = false, Supports MessageService Contract = false, Supports SuperCredentials Contract = true, Supports Preference Contract = true, Supports ContentTransfer Contract = true]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. [2025-07-01 06:26:22,998] Artifact ecm-sf5-cn: Error during artifact deployment. See server log for details.
07-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值