Tomcat 部署 Web应用程序(5)

处理步骤说明:

1、  请求被8080端口监听的Connector1接收到

2、  Connector1把请求交给共享的Engine处理

3、  Engine根据HTTP请求头里面的主机头Host决定该交给那个虚拟主机处理,很明显这里主机头是locahost,因此交给locahost这个虚拟主机处理

4、  虚拟主机根据Context决定请求交给哪个应用程序上下文处理,这里客户端1发出的请求将交给app1处理。

 

 

示范:

静态部署这里不示范,这里示范动态部署。

一、通过拷贝到webapps目录来实现动态部署

我的d盘根目录有一Web应用程序app1:


先将其直接拷贝到webapps目录下:


观察Tomcat的日志输出:


如下:

信息: Deploying web application directory E:\WorkSpace\JavaWorkspace\Tomcat 7.0\webapps\app1

2012-6-3 23:18:31 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info

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

2012-6-3 23:18:31 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info

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

2012-6-3 23:18:31 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info

信息: Parsing configuration file [struts.xml]

说明拷贝进去的项目被自动部署了。

我们再次删除这个项目,但是提示:


这个是因为应用中的jar包被锁定的缘故,查看tomcatContext属性,如下:

:8080/docs/config/context.html

antiJARLocking

 

If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value isfalse.

antiJARLocking is a subset ofantiResourceLocking and therefore, to prevent duplicate work and possible issues, only one of these attributes should be set totrue at any one time.

 

我们修改conf/ context.xml,添加属性antiResourceLocking=true,如下:

<Context antiResourceLocking="true">

 

    <!-- Default set of monitored resources -->

    <WatchedResource>WEB-INF/web.xml</WatchedResource>

 

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->

    <!--

    <Manager pathname="" />

    -->

 

    <!-- Uncomment this to enable Comet connection tacking (provides events

         on session expiration as well as webapp lifecycle) -->

    <!--

    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />

    -->

 

</Context>

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

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