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.
For me same error came. I found old version of Servlet (2.5) existed in my path along with servlet 3.0. Once i remove(exclude) old version my issue solved.
I just had this problem myself and wanted to share it:
javax.servlet:servlet-api:3.0-alpha-1
, with scope provided
, so that it does not interfere with the container that my WAR is ultimately deployed ontoorg.eclipse.jetty:jetty-webapp
, with scope test
, so that I can run Jetty Server as part of my unit testsorg.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016
, needed by jetty-webapp
Exclusion of jetty.orbit:javax.servlet
is no option (for me) because Jetty Server
needed a javax.servlet.HttpConstraintElement
that's not offered by javax.servlet:servlet-api:3.0-alpha-1
. I ended up doing this:
javax.servlet:servlet-api
jetty.orbit:javax.servlet
, with scope provided
, hence fully replacing javax.servlet:servlet-api
I don't know what the deal is with the HttpConstraintElement
that it needed; perhaps it'll be available in future versions of javax.servlet:servlet-api
, which sorta feels to be a preferable dependency over Jetty's implementation of the same.
Edit:
By the way, the problem got introduced by me by fiddling with the configuration of a plugin that automatically formats POM files. It reordered dependencies and as such works against the solution of another poster to reorder the POM file. In my vast Maven experience: if you're "dependent" on the order of your dependencies, that's a major smell.