15 Ekim 2010 Cuma

Maven class loading issues

Recently, I have tried to port one of our project to maven. When I try to use tomcat maven plugin,  I have got the below exception;

java.lang.ClassCastException: tr.com.belsis.common.web.utils.InitServlet cannot be cast to javax.servlet.Servlet at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)

Multiple javax.servlet.Servlet at class path causes this exception. The solution is to define the scope of servlet dependency as provided as below;

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>