手机版
你好,游客 登录 注册
背景:
阅读新闻

Tomcat 部署 Web应用程序

[日期:2012-06-05] 来源:Linux社区  作者:jiangtongcn [字体:大 中 小]

处理步骤说明:

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包被锁定的缘故,查看tomcat的Context属性,如下:

http://localhost: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>

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款