Archives How to Make Embedded Tomcat Support Hot Deploy
Post
Cancel

How to Make Embedded Tomcat Support Hot Deploy

If you search “embedded tomcat” in google, you will get a bunch of instructions how to do this, but non of them mentioned how to enable hot deploy.

1
2
3
4
5
6
Embedded embedded = new Embedded();
 
// create engine, host, connector, context
...
 
embedded.start();

The above code will not enable hot deploy by default. So what we need to do is adding a LifeCycleListener to the host we create.

1
2
3
4
5
6
7
8
9
10
11
12
Embedded embedded = new Embedded();
 
...
 
StandardHost host = (StandardHost) embedded.createHost("localhost",
        getHome() + "/webapps");
host.setAutoDeploy(true);
host.setDeployOnStartup(true);
host.addLifecycleListener(new HostConfig());
 
...
embedded.start();

And the following things are the same as the stand alone Tomcat: define “.xml” and put war files or directory to “/webapps”.

One more thing about how to deploy the default web app:

  • use ROOT.xml, and ROOT.war
  • or use ROOT.xml and define “docBase” pointing to the war file or directory which should not be under “appBase”, and you can name the war or directory anything you like; if symbolic link is used and the original war file or directory get modified, your web app will also be redeployed
This post is licensed under CC BY 4.0 by the author.

用iPhone上的Skype打国内电话

关于Lift的一些事情

Comments powered by Disqus.