Cannot close connection, finalizing with closed connection.

Source: Internet
Author: User

This problem made me an all-night problem. Well, the following is a solution from my brother. I tried it. Thank you.

A small bug in the "my Think Tank" Project

Http://www.zhinangtuan.net.cn/show/20081/20081311205269884.html

Disclaimer: This article is not a problem. It is just a small Vulnerability I found when running the "my Think Tank" project. I would like to share it with mldn and hope you will discuss it actively.
The following problems often occur when running this project:
   ForgotToCallClose ()OnYourSession?
In severe cases, the following exception occurs:
   Org. hibernate. Exception. genericjdbcexception:CocouldNotExecuteQuery
The reason is that spring initializes twice:
The first is in Web. xml.
<Context-param>
    <Param-Name> contextconfiglocation </param-Name>
    <Param-value>
         /WEB-INF/classes/applicationcontext. xml
    </Param-value>
</Context-param>
Second in struts-config.xml
<Plug-in
    Classname = "org. springframework. Web. Struts. contextloaderplugin">
    <Set-PropertyProperty = "contextconfiglocation"
         Value = "/WEB-INF/classes/applicationcontext. xml"/>
</Plug-in>
So how can we initialize it only once?
You cannot delete one entry. An exception occurs when you delete the entry:
Org. springframework. Beans. Factory. beandefinitionstoreexception: 
IoexceptionParsingXMLDocumentFromServletcontextResource[/WEB-INF/applicationcontext. xml];
NestedExceptionIsJava. Io. filenotfoundexception:CocouldNotOpenServletcontextResource[/WEB-INF/applicationcontext. xml]
Java. Io. filenotfoundexception:CocouldNotOpenServletcontextResource[/WEB-INF/applicationcontext. xml]
From this information we can see that Tomcat boot will load once, and the default directory is under/WEB-INF. Spring will be initialized once even if you delete it.
You can only delete 2nd entries. Indeed, after deletion, the exception will not appear. Ensure that spring is only initialized once

★★★Question supplement★★★(20:17:11)
There is a solution if you add this file action-servlet.xml!
1. Put applicationcontext. XML in/WEB-INF.
2. Add only action-servlet.xml to the plug-in at the second place, the Code is as follows:
<Plug-in
    Classname = "org. springframework. Web. Struts. contextloaderplugin">
    <Set-PropertyProperty = "contextconfiglocation"
         Value = "/WEB-INF/action-servlet.xml"/>
In addition, put applicationcontext. xml also put/WEB-INF/, in the web. xml file can also write like this:
    
       Org. springframework. Web. Context. contextloaderlistener
    

★★★Question supplement★★★(20:19:11)
Filtered and sent again!
[Listener]
 [Listener-class]
   Org. springframework. Web. Context. contextloaderlistener
 [/Listener-class]
[/Listener]

★★★Question supplement★★★(20:22:26)
HoweverListenerI guess Tomcat cannot be used.

★★★Question supplement★★★(17:12:09)
I have read the above supplements and have any questions. Please try the following methods:
Directory structure. See the following figure.
Http://hi.baidu.com/java%5Forg/album/item/c06680faef9573d0b58f3127.html
Download the configuration file:
Http://pickup.mofile.com/5707700987067459

★★★Question supplement★★★(11:46:12)
The new configuration file:
Http://pickup.mofile.com/7718233563555967
If you cannot download it, I cannot download it!
Please do not use the previous

★★★Question supplement★★★(11:50:55)
Thank you for your participation!
Download it!

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.