Tomcat 部署 Web应用程序(6)

再次删除app1,就不会有上面的提示了。删除app1后我们观察日志输出:

信息: Undeploying context [/app1]

2012-6-3 23:27:02 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

严重: The web application [/app1] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@3ca56f]) and a value of type [Java.lang.Object[]] (value [[Ljava.lang.Object;@191394e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

2012-6-3 23:27:02 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

严重: The web application [/app1] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@3ca56f]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@149494e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

2012-6-3 23:27:02 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

严重: The web application [/app1] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@3ca56f]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@6bbb36]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

2012-6-3 23:27:02 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

严重: The web application [/app1] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@3ca56f]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@d006a7]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

 

二、通过为Web应用程序添加一个特定的Context文件来实现动态部署

           我们找到以下位置:conf/Catalina/localhost,这个目录代表什么?

           Catalina代表server.xml文件里面配置的默认的Service的名称。

           Localhost代表Service里面的默认虚拟主机名称。

           我们现在就是要在这个虚拟主机里面部署我们的应用。

           做法:

1、  创建一个xml文件,文件名和Web应用名相同:app1.xml

2、  这个文件的内容如下:

a)         <Context path="/app1" docBase="d:/app1" debug="0" privileged="true" workDir="d:/app1work"></Context>

3、  将这个文件拷贝到conf/Catalina/localhost下面,完整路径就是conf/Catalina/localhost/app1.xml,这时Tomcat会自动扫描到这个文件然后根据里面的描述加载应用上下文的。

4、  观察现在的日志输出:

l  信息: Deploying configuration descriptor E:\WorkSpace\JavaWorkspace\Tomcat 7.0\conf\Catalina\localhost\app1.xml

l  2012-6-3 23:41:23 org.apache.catalina.startup.SetContextPropertiesRule begin

l  警告: [SetContextPropertiesRule]{Context} Setting property 'debug' to '0' did not find a matching property.

l  2012-6-3 23:41:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info

l  信息: Parsing configuration file [struts-default.xml]

l  2012-6-3 23:41:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info

l  信息: Parsing configuration file [struts-plugin.xml]

l  2012-6-3 23:41:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info

l  信息: Parsing configuration file [struts.xml]

5、  删除这个文件后,日志输出:

l  信息: Undeploying context [/app1]

l  2012-6-3 23:43:06 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

l  严重: The web application [/app1] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1f1a3a8]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@12f9ee1]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/b03e4bff5f661cbd33ba2fc0fcade0a8.html