Tomcat7无法转换为javax.servlet.Servlet

时间:2019-01-18 17:06:09

标签: web-services tomcat7 classcastexception

我们正在将应用程序迁移到Tomcat7,以下代码在Apache + Jboss中运行正常,但是当我尝试在Tomcat7中运行它时,出现以下错误。

SEVERE: Servlet /acs threw load() exception
java.lang.ClassCastException: com.acs.api.AcsApiImpl cannot be cast to javax.servlet.Servlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)

网络服务:

import javax.jws.WebService;
@WebService(endpointInterface = "com.acs.api.AcsApiInterface")
public class AcsApiImpl implements AcsApiInterface {
}

Web.xml

 <servlet>
        <servlet-name>AcsApi</servlet-name>
        <servlet-class>com.acs.api.AcsApiImpl</servlet-class>
        <load-on-startup>19</load-on-startup>
    </servlet>

Pom.xml

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

        <!-- added these for Embedded Tomcat -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
            <version>7.0.40</version>
        </dependency>
        .....

0 个答案:

没有答案