Deploying to servlet containers

If you're coming from a non-Java background, you may find the subject of
servlet containers and JVM deployments to be unnecessarily frightening. Don't
despair. Despite all the mystery which surrounds them, servlet deployments are
extremely simple. You will be surprised at how easy it is!

Compatibility

Scalatra 2.2 runs on any servlet container which supports the Servlet 3.0 standard.

If you’re using an older container, you’ll need to run the older Scalatra 2.0.x series.

As a war file

The simplest way to deploy your Scalatra application is as a Web ARchive (WAR)
file. With any luck, your app can be up and running in a production configuration
about 5 minutes from now.

From the command line, execute the following:

$ sbt

Now you’re in the sbt console. Package your application by typing package:

This will generate a WAR file for you, and tell you where it went. A WAR file
is basically a zip file which contains your entire application, including all
of its compiled Scala code, and associated assets such as images, javascript,
stylesheets.

Your own servlet container

Now that you’ve got a WAR file, you can run it in a servlet container - there are certainly
lots to choose from.

What follows is not a best-practice guide for configuring Tomcat.
It's aimed at people who are new to servlet containers, and want to see their
application working. Servlet container configuration can be as potentially complex
as other web servers, such as Apache or Nginx, and it's up to you to understand
the performance and security implications of what you're doing. We recommend
that you read the docs on your chosen servlet container before exposing yourself
to the public internet.

Having said all that, the basic case is extremely easy, as you'll see in a moment.

Tomcat paths are case-sensitive. Make sure you copy your app to `ROOT.war`.

Request body params dont get parsed in 'put(/:resource)' api when deploying scalatra app as a WAR in Tomcat 7. To make your PUT work, set the connector attribute 'parseBodyMethods' to 'POST,PUT' in server.xml of tomcat. The same goes for PATCH.