Registered the JDBC driver [Com.mysql.jdbc.Driver] but failed to unregister it when the Web application was stopped.

Source: Internet
Author: User

It's no problem to use the TOMCAT7 plugin to publish a project in eclipse when you're using MAVEN to integrate SSH into your profile recently, but the following error occurs when you publish the project separately using TOMCAT7 after packaging the war.

Severity: Context [/Wangxin] Startup failed due to previous errors August16, 2017 7:29:12afternoon org.apache.catalina.loader.WebappClassLoaderBase Clearreferencesjdbc Serious: The Web application [/Wangxin] registered the JDBC driver [Com.mysql.jdbc.Driver] but failed to unregister it when the Web application is s Topped. To prevent a memory leak, the JDBC Driver have been forcibly unregistered. August16, 2017 7:29:12afternoon org.apache.catalina.loader.WebappClassLoaderBase Clearreferencesthreads Serious: The Web application [/wangxin] appears to has started a thread named [Timer-0] but had failed to stop it. This was very likely to create a memory leak. August16, 2017 7:29:12afternoon org.apache.catalina.loader.WebappClassLoaderBase Clearreferencesthreads Serious: The Web application [/wangxin] appears to has started a thread named [com.mchange.v2.async.threadpoolasynchronousrunner$poolthread-#0] but had failed to stop it. This was very likely to create a memory leak. August16, 2017 7:29:12afternoon org.apache.catalina.loader.WebappClassLoaderBase Clearreferencesthreads Serious: The Web application [/wangxin] appears to has started a thread named [com.mchange.v2.async.threadpoolasynchronousrunner$poolthread-#1] but had failed to stop it. This was very likely to create a memory leak. August16, 2017 7:29:12afternoon org.apache.catalina.loader.WebappClassLoaderBase Clearreferencesthreads Serious: The Web application [/wangxin] appears to has started a thread named [com.mchange.v2.async.threadpoolasynchronousrunner$poolthread-#2] but had failed to stop it. This was very likely to create a memory leak. August16, 2017 7:29:12afternoon org.apache.catalina.loader.WebappClassLoaderBase Clearreferencesthreads Serious: The Web application [/wangxin] appears to had started a thread named [MySQL Statement cancellation Timer] but had failed to stop it. This was very likely to create a memory leak.

This error means: In the TOMCAT7 boot time, the Tomcat comes with a memory check listener found that your project using a database connection pool, and did not close the case, and then to register a connection pool, in order to ensure that the memory does not leak, so you do not allow the deployment of the project.

Theoretically, using the SSH framework to integrate the database, using the JPA and C3P0 connection pool, is not need to care about to close the connection and GC, but still error, for this, it is very doubtful.

The theory on the web is that because TOMCAT7 uses a listening technique, it does so and can be turned off completely. But in fact, after I shut down, although the start is not an error, but can not be deployed, the log is still this error.

Similarly, the online also said a method, is to put the database jar package under Tomcat Lib, I tried or useless.

The final layer of troubleshooting, found that the error is now on my applicationcontext.xml, in order to facilitate development, I put applicationcontext.xml inside the JDBC aspects of all extracted out, Put in a sex applicationcontext-jdbc.xml file, and use the <import> tag to insert in the total XML.

Then I found my web. xml file configuration to be a little different, that is, the CLASSPATH configuration error of the spring listener

< Context-param >     < Param-name >contextconfiglocation</param-name>     <  Param-value>classpath:applicationcontext*.xml</param-value  ></context-param>

I've added one more to the classpath over there.

The correct code:

 <  context-param  >  <  param-name  >  contextconfiglocation</      Span style= "COLOR: #800000" >param-name  >  <  param-value  >  classpath:applicationcontext.xml</  param-value  >  </ context-param  > 

Because of the more than one *, which results in the loading of the APPLICATIONCONTEXT-JDBC when the load, and then load the contents of ApplicationContext, when loading Appliactioncontext, Again to load the inside <import> tag import applicationcontext-jdbc content, which caused a project to load two database connection pool, resulting in a duplicate load, the project can not start the problem.

For the configuration of Web. XML, here I have to say a very angry question.

I do not know what the previous situation, in the Wef-inf automatically generated a classes folder, and then there is a folder inside a ApplicationContext file (in theory, build into the target inside the Wef-inf folder), which caused, When modifying the XML file inside the resource, there was no modification to the file inside the classes, so a tragic scene took place:

Using the SSH framework integration, when using SPRINGJPA integration, wrote a action,action inside is the use of annotations, injected service,service inside with annotations injected Dao,dao only write an interface, The interface inherits the Jparepository.

Using JUnit to invoke the service inside method directly, can obtain the data inside the database, but uses the Tomcat to run, the call action obtains the data. No error at all, using debug to find, in the process of running, The service and DAO are not injected. That is, null.

The result is that, under the Classes folder in the MAVEN project, the resource is copied all over automatically, and the configuration file inside the Mavenresource is modified, which leads to This error is caused by the different applicationcontext.xml files used by JUnit and Tomcat at runtime. At the same time, in Web. XML, the listener that configures spring uses the

< Param-value >classpath*:applicationcontext.xml</param-value>

That is, loading all of the classpath XML files below, which creates the case that spring auto-injection can be loaded at JUnit, but the use of Tomcat is not loaded and no error is made ....

On these two errors about Web. XML, with June Mutual encouragement!

Registered the JDBC driver [Com.mysql.jdbc.Driver] but failed to unregister it when the Web application was stopped.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.