心情烦躁的图片和说说:TCD of tomcat

来源:百度文库 编辑:偶看新闻 时间:2024/05/03 00:42:19

Apache offers a tool called TCD (Tomcat Client Deployer) which can be used to deploy web application REMOTELY.

The tool relies on Tomcat Manager application.

TCD can be easily integrated into ANT build script. Along with TCD distribution there is a template build.xml. I extract some common information and add some information useful to myself.

Properties used by this build file are from two external sources. One is the global properties file, which contains properties that suitable to all my web applications. Properties defined in this file should be identical to all applications. The other one is a project-specific properties file. This one should be placed into the root folder of the project.

The global properties file is,

tomcat.manager.url=http://192.168.140.100:8080/manager

tomcat.manager.username=admin

tomcat.manager.password=admin

tomcat.deployer.jars.dir=C:/Java/apache-tomcat-5.5.20-deployer/lib

The project-specific properties file,

 

# The location containing your source files

src=src

# The location containing the exploded web application

webcontent=WebContent

# The context path of the web application

contextpath=/myWebapp

 

The complete ANT build file is:

 
 
 
 
 
   
  
   
 
 
     
   
     
   

 
 
             classpathref="deployer.classpath"/> 
 
   
 
            depends="clean">
   
  
   
     
   

   
  
                 uriroot="${webapp.path}"
             webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
             addWebXmlMappings="true"
             outputDir="${webapp.path}/WEB-INF/classes" />
  
       
                   optimize="off"
           debug="${compile.debug}"
           deprecation="${compile.deprecation}"
           failonerror="false"
           srcdir="${src.dir}"
           encoding="UTF-8"
        excludes="**/*.smap">
     
       
         
       

       
         
       

     

     
     
   

  
   
             basedir="${webapp.path}" /> 
 
                path="${path}" war="${webapp.path}.war" update="true" />
 
 
                  path="${path}"/>
 
 
 
               path="${path}"/>
 

 
                path="${path}"/>
 

 
              path="${path}"/>
 
 
 In above build file, task will compile all JSPs

 

uriroot="${webapp.path}"

webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"

addWebXmlMappings="true"

outputDir="${webapp.path}/WEB-INF/classes" />

 

webXmlFragment attribute specifies the name of the web.xml fragment generated by jasper2 during the JSP compilation.

 

addWebXmlMappings = true will cause jasper automatically  merge the ${webapp.path}/WEB-INF/generated_web.xml with the current web application deployment descriptor at ${webapp.path}/WEB-INF/web.xml.  

Reload won‘t transfer war file to server. It just tells server to reload the specified web application from server local file system. So it is more useful to be used with local Tomcat and an exploded web application.

   QuestionI wonder why the jasper2 task is called prior to javac. I think javac should be performed first to get the freshest  class file, then copy the folder of webcontent and do JSP compilation. The copy won‘t overwrite the freshest class file as we don‘t let it do so via overwrite attribute.