本文共 2680 字,大约阅读时间需要 8 分钟。
这几天在开发的过程,使用mvn tomcat7:redeploy
命令打包部署到服务器上是,发现有报内存泄漏的日志。于是想在本地测试一下,看是哪里没有释放好内存。日志如下:
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.21-Jul-2018 09:54:55.965 WARNING [http-nio-52000-exec-31] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [iicc_inf] 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:64) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) java.lang.Thread.run(Thread.java:748)21-Jul-2018 09:54:55.966 WARNING [http-nio-52000-exec-31] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [iicc_inf] appears to have started a thread named [Thread-17] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.net.SocketInputStream.socketRead0(Native Method) java.net.SocketInputStream.socketRead(SocketInputStream.java:116) java.net.SocketInputStream.read(SocketInputStream.java:171) java.net.SocketInputStream.read(SocketInputStream.java:141) java.io.BufferedInputStream.fill(BufferedInputStream.java:246) java.io.BufferedInputStream.read1(BufferedInputStream.java:286) java.io.BufferedInputStream.read(BufferedInputStream.java:345) com.sun.jndi.ldap.Connection.run(Connection.java:860) java.lang.Thread.run(Thread.java:748)21-Jul-2018 09:54:56.015 INFO [http-nio-52000-exec-31] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive
可能是因为是spring-boot项目的原因,所以我在tomcat中删除项目时,控制台上并没有打印日志。所以我想把manager加上,这样我可以在控制台上卸载项目,命令行一样卸载的目的。这就需要修改Server Locations了,以下说明Server Locations几项目设置。
Server Locations包括三个选项:
我们平时使用的配置都是第一项,tomcat启动的时候,war包和日志实际的路径可以在Open launch configuration
这里找到:
我今天要使用的是第二项Use Tomcat installation
,启动后,可以在tomcat的目录下看到wtpwebapps
目录(其中wtpwebapps目录可以改为webapps,因不想影响里边的程序就没改),并且在logs目录下也能看到访问日志。
然后在%tomcat%/conf/tomcat-users.xml
增加用户,再从http://localhost:8080/manager/html
登录就可以部署和卸载war应用了。
转载地址:http://lwjta.baihongyu.com/