`

运行期在WebRoot下创建目录会导致tomcat重新加载应用

阅读更多

目前维护的一个系统很是奇怪,必须将servers的publishing选项设置为never publish automatically,否则一登录系统tomcat立马重新加载应用,但是更改设置之后也不爽,对代码作出的修改不能立即生效了。真可谓是不想让你重启吧你非要重启,想让你重启吧还要点击一下publish to the server,令我郁闷之极。

 

光郁闷不行,得想办法解决啊,于是乎,开始断点调试,我看到底是哪个惹的祸。最后,定位到一块在web根目录下创建目录的操作代码段,只要执行完那句,立马让tomcat重新加载,非常好使。

 

我暂时想到的办法是,要么把这个目录移到webroot的外部,要么把创建目录改为创建不同名的文件,要么不改了顶多手工重启tomcat吧。

 

我非常好奇的是,除此之外还有什么别的办法呢,望遇到过此类问题的同路人能够指点迷津。

 

附上tomcat自动重新加载应用的控制台输出

2009-9-4 14:38:22 org.apache.catalina.core.StandardContext reload
信息: Reloading this Context has started
2009-9-4 14:38:25 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stopped already.  Could not load com.mysql.jdbc.profiler.ProfilerEventHandlerFactory.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
 at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4315)
 at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1461)
 at com.ibatis.common.jdbc.SimpleDataSource.forceCloseAll(SimpleDataSource.java:507)
 at com.ibatis.common.jdbc.SimpleDataSource.finalize(SimpleDataSource.java:738)
 at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
 at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
 at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
 at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)

 

3
1
分享到:
评论
2 楼 fangwei 2009-09-08  
ansjsun 写道
你可以修改conf/server.xml  
  配置  
  <context   path=""   debug="0"   docbase=""   reloadable="true">  
  reloadable="true"就表示tomcat在有变化时会自动加载,但他会浪费服务器资源 

谢谢,eclipse中tomcat默认的部署方式就是reloadable="true",我是想让它在发现诸如java,jsp,xml,property等文件的改动后自动重加载,但是不希望在我创建一个目录时重加载
1 楼 ansjsun 2009-09-08  
你可以修改conf/server.xml  
  配置  
  <context   path=""   debug="0"   docbase=""   reloadable="true">  
  reloadable="true"就表示tomcat在有变化时会自动加载,但他会浪费服务器资源 

相关推荐

Global site tag (gtag.js) - Google Analytics