Caucho maker of Resin Server | Application Server (Java EE Certified) and Web Server


Resin Documentation

Aug 2012: Resin outscales C-based web server nginx in AutoBench benchmark
Feb 2012: NetCraft survey says Resin experiencing strong growth in last year and used in number of the Million Busiest Sites.
home company blog wiki docs 
app server web server 
health cloud java ee pro 
 Resin Server | Application Server (Java EE Certified) and Web Server

deploying web-applications

Resin's deployment capabilities include clustered deployment, remote deployment, versioning and rollback, command-line deployment, browser deployment, and standard webapps directory filesystem deployment.


Resin's .war application deployment can be as simple as copying a .war file to a webapps/ directory on a local machine, and as powerful as cloud deployment, archiving, staging, rollback.

  • cloud deployment: Resin's cloud deployment will distribute a new web-application to all servers in the cloud, using a transactional store to ensure consistency.
  • activation control: deployment and activation can be controlled independently, allowing applications to be deployed and verified on all servers, and then activated at once or on a rolling-server basis.
  • archiving and rollback: deployed web-applications can be archived and quickly rolled-back if a deployment needs to be reversed.
  • staging: an application can be deployed to the cluster as a "preview" stage, which will be used only by a preview server.
  • graceful version upgrading: web-applications can be deployed with versions, letting current user continue with the old version and moving new users to the new version.
  • command-line: web-applications can be deployed to the cloud from the command-line for scriptable deployment.
  • browser: for convenience, applications can also be deployed from a browser using the /resin-admin site.

Basic Deployment Methods

Webapps Directory Deployment

For a simple deployment, you can copy a .war archive file containing your application to a webapps directory. Resin will detect the .war archive, expand it, and start serving requests.

The webapps directory is configured and enabled by the <web-app-deploy/> tag in the resin.xml.

Example: web-app-deploy in resin.xml
<resin xmlns="">

<cluster id="">
  <host id="">
    <web-app-deploy path="webapps"

The expand-preserve-fileset attribute lets you keep files for a redeployment, which can improve restart times. Normally, Resin will delete all files for an update, including the compiled files for JSP, which forces Resin to recompile JSP files, even if they haven't changed in the update. If you add the expand-preserve-fileset, Resin will only recompile the JSP files that have changed.

Command-Line Deployment

Command-line deployment uses the same resin.xml <web-app-deploy> configuration as a webapps deployment and expands the archive to the same directory. Instead of looking for the .war file in a directory, Resin will look in an internal repository using the web-app's identifier.

Example: command-line deployment
unix> resinctl deploy test.war

The default deployment is to the default host with the war's name as a prefix. Both can be changed with deploy options.

Command-Line vs Directory Priority

The command-line deployment takes priority over the directory deployement, because a deployment to a cluster ensures that all servers have the same version of the application. This means you must undeploy a web-app from the command-line if you decide to switch from command-line deployment to directory deployment.

Example: command-line undeployment
unix> resinctl undeploy test.war
unix> cp test.war webapps

Deployment Expansion

The <web-app-deploy> controls the expansion based on web-app ids like "production/webapps/default/test" which is the same as the web-app identifier. The deployment expansion process looks like the following:

  1. Look in the internal repository for "production/webapps/default/test" (uploaded by command-line). If an archive exists in the internal repository, skip to step #4.
  2. If that fails, look for a webapps/test.war
  3. If the webapps/test.war exists, copy the test.war into the internal repository as "server/[server-id]/webapps/default/test"
  4. Use the archive in "production/webapps/default/test" (or "server/[server-id]/webapps/default/test") as the repository source archive.
  5. Delete the old webapps/test directory (saving some directories when expand-preserve-fileset is configured.)
  6. Expand the repository source archive files into the webapps/test directory.
  7. Restart the webapp

The deployment identifier matches the web-app id that Resin logs at startup time. The identifier a repository tag that lets Resin have a general cloud repository system and also handle web-app deployments, versioning, and staging.

For the example web-app tag "production/webapp/default/test", the "production" is the deployment stage, "webapp" is because it's a webapp deployment, "default" is the virtual-host name and "test" is the web-app name.

Cloud Deployment

Resin deploys a web-application to all servers in the cluster when you deploy using the command-line or the browser. This process happens automatically and does not require any configuration beyond Resin's normal cluster configuration.

This cloud deployment does not occur when you deploy using the filesystem by placing a .war in a webapps directory. Cloud deployment only occurs on the command-line or browser.

Resin replicates the deployed application to all three triad servers, or to all available server if you have less than three servers. Any server beyond the triad will copy the deployed application from the triad. Normally, you don't need to be aware of the triad, except to make sure at least one of the first three servers is always available.

When you add a new dynamic server or restart a server, the server will check with the triad and update to the most recent copy of the application. The system is reliable if servers crash or even if a server crash or network outage occurs during deployment. Since the deployment is transactional, the new version is only activated when every file has been copied and verified on the server.

Archiving and Rollback

Resin's deployment supports archiving and rollback as part of the underlying system. Like the Subversion version-control-system, you can copy the tag for an application to a unique name. So you can permanently save your webapp as "archive/webapp/foo/2011-05-19" and later rollback to that version if it becomes necessary.

The deployment system associates each .war archive with a tag. A deployed application might look like "production/webapp/". The tag name is the same as the WebApp name in the Resin logs. To archive an application, you copy the tag to an archive name like "archive/webapp/my-app/2011-05-09".

To rollback a version, just copy the archive tag back to the web-app tag.

The following command-line example deploys a war first to the archive and then makes it live using a deploy-copy. The "-stage archive" selects the archive tag.

Example: archive deploy and update
unix> resinctl deploy -stage archive -version 1.2.13 foo.war
Deployed archive/webapp/default/foo-1.2.13 from /tmp/caucho/qa/foo.war \

unix> resinctl deploy-copy \
  -source-stage archive -source-version 1.2.13 -source foo \
  -target foo

Internally, the archived war files are stored with a different tag name. In the previous example, the repository might contain three tags: the archive foo-1.2.12, the archive foo-1.2.13, and the production webapp, which is a copy of foo-1.2.13.

Example: repository tags for archive
archive/webapp/default/foo-1.2.12   -- archived foo.war contents
archive/webapp/default/foo-1.2.13   -- archived foo.war contents
production/webapp/default/foo       -- production foo.war (a copy of 1.2.13)

The current web-app production/webapp-default/foo can be rolled-back by copying it from a previous version.

Example: rolling back to foo.1.2.12
unix> resinctl deploy-copy \
  -source-stage archive -source-version 1.2.12 -source foo \
  -target foo


As a final quality check before making a deployment live, you can deploy the application to a staging "preview" server in the deployment cluster. The preview version will only be visible on the preview server until you copy it to a live machine.

Example: deploying a preview stage
unix> resinctl deploy -stage preview foo.war

unix> resinctl start -stage preview -elastic-server -server dyn1 -cluster app-tier

Internally, Resin stores the preview stage as a repository tag preview/webapp/default/foo. When you deploy the .war with -stage preview, Resin save the deploy under the preview tag name. When you start Resin with -stage preview, you ask it to look in the preview tag for the web-app.

Example: repository tags for staging
preview/webapp/default/foo        -- preview foo.war contents
production/webapp/default/foo     -- production foo.war contents

After you've verified that the previewed application works, you can deploy it to production using the deploy-copy.

Example: deploying a preview as production
unix> resinctl deploy-copy \
  -source-stage preview -source foo \
  -target foo

Activating deployed applications

Applications can be activiated independent of their deployment, letting you upload a new deployment to a cloud, and then activating all servers at once or creating a rolling activation.

By default, activation is automatic. When an application is deployed, it is automatically activated. You can change the default behavior by setting the startup-mode and redeploy-mode for the web-app-deploy.

Startup and Redeploy Modes

The startup-mode is used in a number of places to determine the behaviour of a resource when the server starts.

The startup-mode has three values: "automatic", "lazy", and "manual".

  • automatic - starts the resource on server start (default)
  • lazy - starts the resource on the first use
  • manual - waits for JMX to start the resource

The redeploy-mode is used in a number of places to determine the behaviour of a resource when it is replaced or modified while the server is running.

The redeploy-mode has two values: "automatic", and "manual".

  • automatic - restarts the resource when it is modified (web.xml, *.class, *.war, etc).
  • manual - waits for JMX to restart the resource when changes occur.

Deploying to a live server without interruption

It may be possible to deploy a web application to a live server without interruption to service if certain conditions are met.

  1. The session objects for your users are being persisted.
  2. The usage of session scoped objects between the old version and the new is compatible.
  3. The usage of application scoped objects between the old version and the new is compatible.
  4. Database schema changes are not required.

Resin allows you to have a backup instance running. The idea is that this backup instance of Resin takes over if your primary Resin instance goes down.

If you are using a load balancer to distribute your load to multiple primary servers, each primary server has a backup server.

You can use this feature to deploy to a live server without interruption of service.

  1. shutdown primary server(s) (backup server(s) takes over)
  2. deploy new war to primary server(s)
  3. start primary server(s). As soon as the primary server starts, the user will be using the new version of the application.
  4. deploy new war to backup server(s)

Versioning and Graceful Upgrades

Resin can deploy multiple versions of a web-app simultaneously, simplifying any application upgrades. The old version of the web-app will continue to receive old sessions, while the new version will get the new requests. So any user will see a consistent version as the web site update occurs with no downtime required.

The versioning requires <web-app-deploy>, i.e. it works with the webapps directory. The versioning is numerically-based, allowing dotted notation, to determine the most recent version. A simple deployment process might use foo-101 to upgrade from foo-100. A more complicated one might use foo-10.3.14 to upgrade from foo-10.3.13.

The versioning attribute of the <web-app-deploy> enables versioning:

Example: resin.xml for webapps versioning
<resin xmlns="">
<cluster id="">
<host id="">

  <web-app-deploy path="webapps" versioning="true"


Deployment Methods

Filesystem deployment: Custom web-app with .war file

In this scenario, you want to configure a web-app with a specific root-directory and specify the location of the .war file. As usual, when Resin sees any changes in the .war file, it will expand the new data into the root-directory and restart the web-app. This capability, gives sites more flexibility where their directories and archive files should be placed, beyond the standard webapps directory.

The optional archive-path argument of the <web-app> will point to the .war file to be expanded.

web-app deployment options
archive-pathpath to the .war file which contains the web-app's contents
dependency-check-intervalhow often Resin should check for changes in the web-app for a redeployment2s
expand-preserve-fileseta set of files/directories Resin should preserve on a redeploy when it deletes the expanded directory
idunique identifier for the web-app and the default context-path value
redeploy-check-intervalhow often Resin should check the .war file for changes60s
redeploy-modehow Resin should handle redeployment: automatic, lazy, or manualautomatic
root-directorypath to the expanded web-app directoryid as a sub-directory of the virtual-hosts's root
Example: resin.xml for custom web-app
<resin xmlns="">
<cluster id="">
  <host id="">

    <web-app id="/foo" root-directory="/var/resin/foo"


Command-Line Remote Deployment

The "deploy" command deploys a .war file to the default virtual host. In a cloud environment, Resin will copy the deployed .war to all servers in the cluster. Since the AdminAuthenticator requires a user and password, you'll need to pass those arguments.

Example: deploy hello.war
unix> resinctl deploy hello.war \
           -user foo -password test

Browser-based Remote Deployment

As of Resin 4.0.0, it is now possible to deploy web applications remotely to a shared repository that is distributed across the cluster. This feature allows you to deploy once to any triad server and have the application be updated automatically across the entire cluster. When a new dynamic server joins the cluster, the triad will populate it with these applications as well.

To deploy an application remotely:

  1. log into the resin-admin console on any triad server. Make sure you are connecting over SSL, as this feature is not available over a non-encrypted channel.
  2. Browse to the "webapp" tab of the resin-admin server and at the bottom of the page, enter the virtual host, URL, and local .war file specifying the web application, then press "Deploy".
    Virtual Host:default, URL:/foo, .war file:/tmp/foo.war, Deploy button
  3. The application should now be deployed on the server. In a few moments, all the servers in the cluster will have the webapp.
    WebApps: /:active, /foo:active, /resin-admin:active

Copyright © 1998-2012 Caucho Technology, Inc. All rights reserved. Resin ® is a registered trademark. Quercustm, and Hessiantm are trademarks of Caucho Technology.