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.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
But provided scope adds the classes in this dependency to the classpath when running in test scope, that's a problem for Jetty which I start programmatically. Since it already has it in its library I get a
java.lang.SecurityException: class "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package
If I remove this dependency the Jetty server starts correctly in test scope, but I need this dependency for IntelliJ to compile my code. Whats the best way to solve this, is there a way I can exclude this dependency for the test scope ?
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.
try to set it to compile scope
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With