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
- Public ClassProxoolservletExtendsHttpservlet {
- Public VoidInit ()ThrowsServletexception {
- }
- Public VoidDestroy (){
- Proxoolfacade. Shutdown ();
- }
- Public VoidDopost (httpservletrequest request, httpservletresponse response)Throws
- Servletexception, ioexception {
- Doget (request, response );
- }
- Public VoidDoget (httpservletrequest request, httpservletresponse response)Throws
- Servletexception, ioexception {
- }
- }
Java code
- Public class proxoolservlet extends httpservlet {
- Public void Init () throws servletexception {
- }
- Public void destroy (){
- <SPAN class = hilite4> <span style = "background-color: #00 FFFF"> proxoolfacade </span>. <SPAN class = undefined> shutdown </span> ();
- }
- Public void dopost (httpservletrequest request, httpservletresponse response) throws
- Servletexception, ioexception {
- Doget (request, response );
- }
- Public void doget (httpservletrequest request, httpservletresponse response) throws
- Servletexception, ioexception {
- }
- }
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
- <Servlet>
- <Servlet-Name> proxoolservlet </servlet-Name>
- <Servlet-Class> XXX. proxoolservlet </servlet-Class>
- <Load-on-startup> 1 </load-on-startup>
- </Servlet>
Java code
- <Servlet>
- <Servlet-Name> proxoolservlet </servlet-Name>
- <Servlet-class> XXX. proxoolservlet </servlet-class>
- <Load-on-startup> 1 </load-on-startup>
- </Servlet>
<Servlet> <servlet-Name> proxoolservlet </servlet-Name> <servlet-class> XXX. proxoolservlet </servlet-class> <load-on-startup> 1 </load-on-startup> </servlet>
3. OK