Exception in thread "housekeeper" java. Lang. nullpointerexception

Source: Internet
Author: User

When the proxool connection pool is used to restart the Tomcat container

 

Exception in thread "Housekeeper" Java. Lang. nullpointerexception

 

Null Pointer Exception error.

 

The reason is:

Write this is because proxool is not being
Shutdown properly. if the JVM stops then proxool tables that and shuts down gracefully, But if you redeploy proxool into some environments (for example, a servlet container) Then proxool needs to be explicitly told so by calling
Proxoolfacade. Shutdown (). If you have a servlet container then you cocould put it in the Servlet's destroy () method. Alternatively, use the servletconfigurator
To both configure and shutdown proxool

 

 

The solution is as follows:

 

1. explicitly disable the connection pool proxoolfacade. Shutdown () in the destroy () method of servlet ();

 

Java code
  1. Public ClassProxoolservletExtendsHttpservlet {
  2. Public VoidInit ()ThrowsServletexception {
  3. }
  4. Public VoidDestroy (){
  5. Proxoolfacade. Shutdown ();
  6. }
  7. Public VoidDopost (httpservletrequest request, httpservletresponse response)Throws 
  8. Servletexception, ioexception {
  9. Doget (request, response );
  10. }
  11. Public VoidDoget (httpservletrequest request, httpservletresponse response)Throws 
  12. Servletexception, ioexception {
  13. }
  14. }
Java code
 
  1. Public class proxoolservlet extends httpservlet {
  2. Public void Init () throws servletexception {
  3. }
  4. Public void destroy (){
  5. <SPAN class = hilite4> <span style = "background-color: #00 FFFF"> proxoolfacade </span>. <SPAN class = undefined> shutdown </span> ();
  6. }
  7. Public void dopost (httpservletrequest request, httpservletresponse response) throws
  8. Servletexception, ioexception {
  9. Doget (request, response );
  10. }
  11. Public void doget (httpservletrequest request, httpservletresponse response) throws
  12. Servletexception, ioexception {
  13. }
  14. }
Public class proxoolservlet extends httpservlet {public void Init () throws servletexception {} public void destroy () {proxoolfacade. shutdown ();} public void dopost (httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {doget (request, response);} public void doget (httpservletrequest request, response) throws servletexception, ioexception {}}

 

2. Configure the servlet to Web. xml:

 

Java code
  1. <Servlet>
  2. <Servlet-Name> proxoolservlet </servlet-Name>
  3. <Servlet-Class> XXX. proxoolservlet </servlet-Class>
  4. <Load-on-startup> 1 </load-on-startup>
  5. </Servlet>
Java code
 
  1. <Servlet>
  2. <Servlet-Name> proxoolservlet </servlet-Name>
  3. <Servlet-class> XXX. proxoolservlet </servlet-class>
  4. <Load-on-startup> 1 </load-on-startup>
  5. </Servlet>
<Servlet> <servlet-Name> proxoolservlet </servlet-Name> <servlet-class> XXX. proxoolservlet </servlet-class> <load-on-startup> 1 </load-on-startup> </servlet>

 

3. OK

Related Article

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.