Any reason to use Tomcat rather than Jetty, which is well documented for this use case and commonly used embedded? If you're simply looking for a Servlet container that you can embed, Jetty does this readily.
–
Will HartungMar 12 '09 at 19:11

Thanks for the pointer. However, this doesn't look like it's complete, actively developed, or maintained. All commits are dated May 11, 2008, and one of the log messages calls it "far from complete".
–
otto.poellathMar 20 '09 at 10:05

I also faced the 404 error and struggled some time. By seeing the log 'INFO: No default web.xml', I suspected it (if that is a warning, would've been easy to spot). The trick being using the web.xml( rootContext.setDefaultWebXml("web.xml") ) supplied with Tomcat (conf/web.xml). The reason being, it includes the DefaultServlet, which serves the static files likes HTML, JS. Either use the web.xml or register the servlet manually in your code.

I tried your example, my application goes up, I see spring being initalized but when I try to access my application, I get spring error messages saying that no mappings were found for my jsps.
–
ThiagoFeb 6 '14 at 1:37

A minor update: The org.apache.catalina.startup.Embedded is deprecated and is advised to use org.apache.catalina.startup.Tomcat instead. Making this change many chain changes will follow to make the code runnable.
–
AthafoudDec 1 '14 at 10:19

One is developing web applications that need to be easily transported to a Tomcat installation

The Jetty developer documentation is actually spottier than Tomcat's (amazing!)

Getting questions answered in the Jetty community can sometimes take years, as in 2007. see Embedding Jetty

Important: After Jetty 6.1.*, each web application opens into its own JVM, so if you're trying to gain programmatic access between your standalone access and your web app, your only hope is via a web API.

If it's an issue for you, Tomcat is an open source project who intellectual property is owned by the Apache Foundation, Jetty is open source but owned by a small private company (Mortbay Consulting)

Point #5 has been important in my work. For example, I can gain direct access to a JSPWiki instance via Tomcat, but it's completely inaccessible when using Jetty. I asked for a solution to that in 2007 and haven't yet heard an answer. So I finally gave up and began using Tomcat 6. I've looked into Glassfish and Grizzly, but so far Tomcat is (amazingly) the most stable and well-documented web container (which isn't saying much really).

I'm pretty certain webapps do not open in their own JVM. They use separate classloaders by default. To get the classloader behaviour you want just use webapp.setParentLoaderPriority(true); - I think this is in the Jetty documentation.
–
Paul CagerDec 29 '11 at 17:03

I've used Tomcat, Jetty, and Grizzly all in production and pretty much agree with all that was said in this answer
–
three-cupsDec 15 '12 at 5:22