我正在Eclipse IDE中开发一个spring-rest应用程序。在将应用程序作为maven-build运行时,我收到的错误显示“没有这样的方法”和“在应用程序web.xml中解析错误”
控制台中显示错误:
SEVERE: End event threw exception
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:849)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:201)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1063)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
Mar 25, 2015 10:56:42 AM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at file:/home /vittisysadmin/apache-tomcat-7.0.57/conf/web.xml
org.xml.sax.SAXParseException; systemId: file:/home/vittisysadmin/apache-tomcat-7.0.57/conf/web.xml; lineNumber: 109; columnNumber: 15; Error at (109, 15) : org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2711)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2743)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1066)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
Caused by: java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:849)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:201)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1063)
... 26 more
我的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>com.oreilly.springdata</groupId>
<artifactId>spring-data-book</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>spring-data-book-rest</artifactId>
<name>Spring Data Book - REST exporter</name>
<packaging>war</packaging>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring Data REST -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>1.1.0.M1</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.3.0.RELEASE</version>
</dependency>
<!-- Hibernate / JPA -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.6.Final</version>
<scope>runtime</scope>
</dependency>
<!-- Database -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.8</version>
<scope>runtime</scope>
</dependency>
<!-- Web -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.0.RC2</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-libs-milestone</id>
<url>http://repo.springsource.org/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
我的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
**<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>**
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<!-- The mapping for the default servlet -->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- The mappings for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
<!-- The mapping for the SSI servlet -->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<mime-mapping>
<extension>scurl</extension>
<mime-type>text/vnd.curl.scurl</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sda</extension>
<mime-type>application/vnd.stardivision.draw</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sdc</extension>
<mime-type>application/vnd.stardivision.calc</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sdd</extension>
<mime-type>application/vnd.stardivision.impress</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sdkd</extension>
<mime-type>application/vnd.solent.sdkm+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sdkm</extension>
<mime-type>application/vnd.solent.sdkm+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sdp</extension>
<mime-type>application/sdp</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sdw</extension>
<mime-type>application/vnd.stardivision.writer</mime-type>
</mime-mapping>
<mime-mapping>
<extension>see</extension>
<mime-type>application/vnd.seemail</mime-type>
</mime-mapping>
<mime-mapping>
<extension>seed</extension>
<mime-type>application/vnd.fdsn.seed</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sema</extension>
<mime-type>application/vnd.sema</mime-type>
</mime-mapping>
<mime-mapping>
<extension>semd</extension>
<mime-type>application/vnd.semd</mime-type>
</mime-mapping>
<mime-mapping>
<extension>semf</extension>
<mime-type>application/vnd.semf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ser</extension>
<mime-type>application/java-serialized-object</mime-type>
</mime-mapping>
<mime-mapping>
<extension>setpay</extension>
<mime-type>application/set-payment-initiation</mime-type>
</mime-mapping>
<mime-mapping>
<extension>setreg</extension>
<mime-type>application/set-registration-initiation</mime-type>
</mime-mapping>
<mime-mapping>
<extension>sfd-hdstx</extension>
<mime-type>application/vnd.hydrostatix.sof-data</mime-type>
</mime-mapping>
<mime-mapping>
<!-- Compiled WML Script -->
<extension>wmlsc</extension>
<mime-type>application/vnd.wap.wmlscriptc</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wmv</extension>
<mime-type>video/x-ms-wmv</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wmx</extension>
<mime-type>video/x-ms-wmx</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wmz</extension>
<mime-type>application/x-msmetafile</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff</extension>
<mime-type>application/x-font-woff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wpd</extension>
<mime-type>application/vnd.wordperfect</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wpl</extension>
<mime-type>application/vnd.ms-wpl</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wps</extension>
<mime-type>application/vnd.ms-works</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wqd</extension>
<mime-type>application/vnd.wqd</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xpw</extension>
<mime-type>application/vnd.intercon.formnet</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xpx</extension>
<mime-type>application/vnd.intercon.formnet</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsl</extension>
<mime-type>application/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xslt</extension>
<mime-type>application/xslt+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsm</extension>
<mime-type>application/vnd.syncml+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xspf</extension>
<mime-type>application/xspf+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xul</extension>
<mime-type>application/vnd.mozilla.xul+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xvm</extension>
<mime-type>application/xv+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xvml</extension>
<mime-type>application/xv+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xwd</extension>
<mime-type>image/x-xwindowdump</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xyz</extension>
<mime-type>chemical/x-xyz</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xz</extension>
<mime-type>application/x-xz</mime-type>
</mime-mapping>
<mime-mapping>
<extension>yang</extension>
<mime-type>application/yang</mime-type>
</mime-mapping>
<mime-mapping>
<extension>yin</extension>
<mime-type>application/yin+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z</extension>
<mime-type>application/x-compress</mime-type>
</mime-mapping>
<mime-mapping>
<extension>Z</extension>
<mime-type>application/x-compress</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z1</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z2</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z3</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z4</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z5</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z6</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z7</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>z8</extension>
<mime-type>application/x-zmachine</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zaz</extension>
<mime-type>application/vnd.zzazz.deck+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zip</extension>
<mime-type>application/zip</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zir</extension>
<mime-type>application/vnd.zul</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zirz</extension>
<mime-type>application/vnd.zul</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zmm</extension>
<mime-type>application/vnd.handheld-entertainment+xml</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
任何人都可以帮我解决这个问题。在此先感谢