问题描述:

Tomcat 服务器启动报异常提示数据库驱动不能被注册,当应用被停止时。为了防止内存泄漏,已强制注销JDBC驱动程序。折腾了2小时最后LZ定位问题是出于开发环境与服务器环境JDK版本不一致导致的。

异常信息:

严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
二月 23, 2021 3:14:08 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/usst_app] startup failed due to previous errors
二月 23, 2021 3:14:08 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
严重: The web application [/usst_app] 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.
二月 23, 2021 3:14:08 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
严重: The web application [/usst_app] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
二月 23, 2021 3:14:08 下午 org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
严重: The web application [/usst_app] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5e56f8fc]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) 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.
二月 23, 2021 3:14:08 下午 org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
严重: The web application [/usst_app] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1ff498c7]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) 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.
二月 23, 2021 3:14:08 下午 org.apache.catalina.startup.HostConfig deployDirectory

解决办法:

由于可能导致报该异常的原因比较多, 所有再次罗列几种常见的处理方法仅供参考哦。

方法一:(PS,LZ就是这样解决的)

原因及方案:开发环境的jdk版本必须与服务器上的jdk版本一致,编译的时候才能识别,高版本的编译下的class文件,在低版本下有些方法无法识别。ps LZ本地是1.8,线上环境 1.7

 

方法二

原因及方案: 使用killall 或者 kill -9直接杀死java进程,导致相关内存没有及时释放。这种情况多出于Linux服务器下。使用stop.sh来停止tomcat,然后重新启动就可以了。

 

方法三

原因及方案:对于这样的registered the JDBC driver问题,我初步断定是deploy执行了两次所致。后分析调整后,Host配置应该以下

<Host name="localhost"  appBase="/webroot"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false"> 
		 <Context path=" " docBase="ROOT"/>
</Host>

<Context path=" " docBase="ROOT"/>

path 等于空格  ,不是/或ROOT。


final:以上方案来源于网络,侵删

 

 

 

Logo

一站式 AI 云服务平台

更多推荐