Tomcat - Servlet init() called twice upon startup

倾然丶 夕夏残阳落幕 提交于 2019-12-01 19:46:01

Tomcat is autodeploying anything in webapps, and also deploying according to server.xml. Just remove your webapp from webapps to avoid double loading.

There is a bug in your code. Your singleton is not thread-safe. That getInstance() method should be synchronised. Otherwise you are liable to construct multiple instances.

I would set a breakpoint in the init() method and then look at the stack to see where the calls are coming from.

If the init() method fails, it may be called again on a subsequent get. Did you check the catalina.out file to make sure that the init() call is not being aborted for some reason?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!