I have the following dependency in my pom.xml so that my IDE (IntelliJ) has the servlet-api classes available during compilation, but not provided in the build.
I found the solution when trying not to include javax.servlet-api in the classpath running a junit test. Actually I moved the servlet-api at the very end of the jars in the classpath and enlightment came...
I used the wrong version of the servlet-api. I was using 2.5 but needed 3.0. Maven scope I do choose "provided". Works for running junit inside eclipse and for "mvn test" execution.
Nevertheless, I do not understand why there is no conflict. If I got it right even the "provided" dependencies will be exposed in the classpath when testing, so there could be a conflict - or, of course - if I exactly hit the right versions of the servlet-api used for compilation and the jetty's servlet-api then there is no conflict.
Anyways, it works for me.
Here's my dependencies/* pom-setup for jetty + servlet api:
org.eclipse.jetty
jetty-server
8.1.4.v20120524
jar
test
org.eclipse.jetty
jetty-servlet
8.1.4.v20120524
jar
test
org.eclipse.jetty
jetty-webapp
8.1.4.v20120524
jar
test
org.eclipse.jetty
jetty-jsp
8.1.4.v20120524
jar
test
javax.servlet
javax.servlet-api
3.0.1
provided