Exception in thread "HouseKeeper" java.lang.NullPointerException
Exception in thread "HouseKeeper" java.lang.NullPointerException2011-04-26 08:52虽然这个错误不影响项目,但是项目中的 class 类一改动 就无法自动启动起来了。因为这个错误导致的。很是麻烦!
解决方法:(次方法也是来源于网络中,我只是再次分享。或者把零散的整合在一起说了)
package cn.com.***.***.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.logicalcobwebs.proxool.ProxoolFacade; /** * Servlet implementation class HouseKeeperServlet */ public class HouseKeeperServlet extends HttpServlet { private static final long serialVersionUID = 1L; public void destroy() { //此处添加处理 ProxoolFacade.shutdown(); } /** * @see HttpServlet#HttpServlet() */ public HouseKeeperServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
import org.logicalcobwebs.proxool.ProxoolFacade;
/*
* 此类用来处理 在class类进行修改的时候 保存了之后服务自动重新启动 报:
* Exception in thread "HouseKeeper" java.lang.NullPointerException
* 错误原因为:
* This is because Proxool is not being shutdown properly.
* If the JVM stops then Proxool recognises 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 could put it in the servlet's destroy() method.
* Alternatively, use the ServletConfigurator to both configure and shutdown Proxool
*/
<!-- for resolving HouseKeeper bug--> <servlet> <servlet-name>loadServlet</servlet-name> <servlet-class>cn.com.xxx.xxx.HouseKeeperServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>