ClassCastException happens when I use maven with tomcat plugin

Posted by zjffdu on Stack Overflow See other posts from Stack Overflow or by zjffdu
Published on 2011-01-04T05:48:58Z Indexed on 2011/01/04 5:53 UTC
Read the original article Hit count: 322

Filed under:
|
|

Hi all,

I try to use maven with tomcat plugin to develop a simple web application. But When I invoke the servlet, ClassCastException happens, this is the error message: java.lang.ClassCastException: "com.snda.dw.moniter.LogQueryServlet cannot be to javax.servlet.Servlet"

But I already make com.snda.dw.moniter.LogQueryServlet extends HttpServlet, it should can be cast to avax.servlet.Servlet. The following is my pom.xml

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.snda dw.moniter war 0.0.1-SNAPSHOT dw.moniter Maven Webapp http://maven.apache.org junit junit 3.8.1 test

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

        <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>r07</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.1</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>0.20.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.snda</groupId>
            <artifactId>dw.common</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.flexjson</groupId>
            <artifactId>flexjson</artifactId>
            <version>2.1</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
</dependencies>
<build>
    <finalName>dw.moniter</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.1</version>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>8.0.0.M2</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

© Stack Overflow or respective owner

Related posts about tomcat

Related posts about maven