Netflix/SimianArmy — pull request #54 by nicktgr15 (2013-05-09 10:33:34+00:00)
Title: Explicitly setting servlet load order in web.xml so that Tomcat behaves the same as Jetty

Hello,
It looks like the problem we had with tomcat was related to the load-on-startup parameter used in web.xml.Because it's up to the servlet container (Jetty or Tomcat) which order it loads servlets that have the same value, we noticed the following variation on loading:

Jetty: 1. Monkey Server, 2. jersey-servlet
Tomcat: 1. jersey-servlet , 2. Monkey Server

So we explicitly set a larger number for jersey-servlet to ensure same load order in Tomcat as in Jetty. For details on load order, see snippet from servlet 2.5 specification at the bottom of this post.

### Fixed web.xml

```

Monkey Server
com.netflix.simianarmy.basic.BasicMonkeyServer
1

jersey-servlet
com.sun.jersey.spi.container.servlet.ServletContainer

com.sun.jersey.config.property.packages
com.netflix.simianarmy.resources

2

jersey-servlet
/api/*

```

### Servlet 2.5 Specification snippet

```

The load-on-startup element indicates that this
servlet should be loaded (instantiated and have
its init() called) on the startup of the web
application. The optional contents of these
element must be an integer indicating the order in
which the servlet should be loaded. If the value
is a negative integer, or the element is not
present, the container is free to load the servlet
whenever it chooses. If the value is a positive
integer or 0, the container must load and
initialize the servlet as the application is
deployed. ***The container must guarantee that
servlets marked with lower integers are loaded
before servlets marked with higher integers. The
container may choose the order of loading of
servlets with the same load-on-start-up value.***

```