I am getting this error, when I run mvn tomcat:run
in my web modulo.
SEVERE: Servlet /web threw load() exception
java.lang.ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet
The problem happens when I add a dependency to one other modulo I have, specifically because that other modulo contains com.google.gdata:core
dependency. I ran mvn dependency:tree
I saw that this google dependency has servlet-api
down its dependency tree, and so I think this is the problem. But I dont know how to fix it.
| \- com.google.gdata:core:jar:1.47.1:compile
| +- com.google.guava:guava:jar:13.0.1:compile
| +- com.google.oauth-client:google-oauth-client-jetty:jar:1.11.0-beta:compile
| | +- com.google.oauth-client:google-oauth-client-java6:jar:1.11.0-beta:compile
| | | \- com.google.oauth-client:google-oauth-client:jar:1.11.0-beta:compile
| | | \- com.google.http-client:google-http-client:jar:1.11.0-beta:compile
| | | +- org.apache.httpcomponents:httpclient:jar:4.0.3:compile
| | | | \- org.apache.httpcomponents:httpcore:jar:4.0.1:compile
| | | \- xpp3:xpp3:jar:1.1.4c:compile
| | \- org.mortbay.jetty:jetty:jar:6.1.26:compile
| | +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
| | \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile
| +- com.google.code.findbugs:jsr305:jar:1.3.7:compile
| \- javax.mail:mail:jar:1.4:compile
| \- javax.activation:activation:jar:1.1:compile
This answer suggests making servlet-api
dependency provided
, but how can do this inside a dependency I do not own?