通过Maven在Tomcat上部署Axis2时的AxisServlet ClassCastException

时间:2014-09-25 21:22:44

标签: maven tomcat7 axis2 m2eclipse maven-tomcat-plugin

我正在转换企业应用程序以使用Maven,目前我在使用Maven在Tomcat上部署应用程序时遇到了问题。

我使用M2e,Tomcat 7.0和Axis2 1.70(SNAPSHOT)

我运行两个命令:

dependency:copy-dependencies
tomcat:run -Dmaven.tomcat.port=8380

当我导航到http://localhost:8380/app/services/SimpleService?wsdl时,服务器JVM会抛出ClassCastException。

Sep 25, 2014 3:56:01 PM org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
Sep 25, 2014 3:56:01 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
Sep 25, 2014 3:56:02 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\stephen\Code\Java\7\ECSApp\src\main\webapp\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Sep 25, 2014 3:56:02 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\stephen\Code\Java\7\ECSApp\src\main\webapp\WEB-INF\lib\tomcat-servlet-api-8.0.12.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Sep 25, 2014 3:56:02 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8380
Sep 25, 2014 3:56:02 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8380
Sep 25, 2014 3:56:40 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet AxisServlet as unavailable
Sep 25, 2014 3:56:40 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet AxisServlet
java.lang.ClassCastException: org.apache.axis2.transport.http.AxisServlet cannot be cast to javax.servlet.Servlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:724)

有没有人知道如何解决此错误?

这是我的pom.xml供参考:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>ad</groupId>
    <artifactId>ecs</artifactId>

    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>ad.ecs</groupId>
  <artifactId>app</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>ECSApp</name>
  <url>http://www.myorganization.org</url>
  <properties>
    <neethiReleaseVersion>2.0</neethiReleaseVersion>
    <rampartReleaseVersion>1.4.1</rampartReleaseVersion>
    <axiomReleaseVersion>1.2.14</axiomReleaseVersion>
    <wodenReleaseVersion>1.0M8</wodenReleaseVersion>
    <axis2ReleaseVersion>1.7.0-SNAPSHOT</axis2ReleaseVersion>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.apache.axis2</groupId>
      <artifactId>axis2-transport-http</artifactId>
      <version>${axis2ReleaseVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.axis2</groupId>
      <artifactId>axis2-transport-local</artifactId>
      <version>${axis2ReleaseVersion}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.axis2</groupId>
      <artifactId>axis2</artifactId>
      <version>${axis2ReleaseVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-api</artifactId>
      <version>${axiomReleaseVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-impl</artifactId>
      <version>${axiomReleaseVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-dom</artifactId>
      <version>${axiomReleaseVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.schema</groupId>
      <artifactId>XmlSchema</artifactId>
      <version>1.4.2</version>
    </dependency>
    <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>3.0.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.woden</groupId>
      <artifactId>woden-api</artifactId>
      <version>${wodenReleaseVersion}</version>
      <exclusions>
        <exclusion>
          <artifactId>xercesImpl</artifactId>
          <groupId>xerces</groupId>
        </exclusion>
        <exclusion>
          <artifactId>xml-apis</artifactId>
          <groupId>xml-apis</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.woden</groupId>
      <artifactId>woden-impl-dom</artifactId>
      <version>${wodenReleaseVersion}</version>
      <exclusions>
        <exclusion>
          <artifactId>xercesImpl</artifactId>
          <groupId>xerces</groupId>
        </exclusion>
        <exclusion>
          <artifactId>xml-apis</artifactId>
          <groupId>xml-apis</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>backport-util-concurrent</groupId>
      <artifactId>backport-util-concurrent</artifactId>
      <version>3.1</version>
    </dependency>
    <dependency>
      <groupId>annogen</groupId>
      <artifactId>annogen</artifactId>
      <version>0.1.0</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.neethi</groupId>
      <artifactId>neethi</artifactId>
      <version>2.0</version>
    </dependency>

    <dependency>
      <groupId>ad.ecs.db</groupId>
      <artifactId>legacy</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>ad.ecs</groupId>
      <artifactId>asyncservice</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>ad.ecs</groupId>
      <artifactId>alarmservice</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </dependency>    
  </dependencies>
  <repositories>
    <repository>
      <id>axis2m</id>
      <name>Axis2m Repository</name>
      <url>http://axis2m.sourceforge.net/repo/</url>
    </repository>
    <repository>
      <id>apache-snapshots</id>
      <url>http://repository.apache.org/snapshots/</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>axis2m</id>
      <name>Axis2m Repository</name>
      <url>http://axis2m.sourceforge.net/repo/</url>
    </pluginRepository>
    <pluginRepository>    
      <id>apache-snapshots</id>
      <url>http://repository.apache.org/snapshots/</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <finalName>ECSApp</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <optimize>true</optimize>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <outputDirectory>
            ${project.build.directory}
          </outputDirectory>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

1 个答案:

答案 0 :(得分:0)

您的类路径中似乎有重复的jar文件