现在我尝试使用tomcat7-maven-plugin将我的war文件从IntelliJ IDEA部署到tomcat 7
并面临另一个问题。
这是pom.xml的设置:
<build>
<finalName>employee-list</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://127.0.0.1:8080/employee-list</url>
<server>TomcatServer</server>
<path>/employee-list</path>
</configuration>
</plugin>
</plugins>
</build>
这是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>employee-list</display-name>
<!-- Spring MVC configurations-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-security.xml
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/employee/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring Security configurations-->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
所以,我使用org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy -e
tomcat7-maven-plugin
并获得此调试日志:
[INFO] <<< tomcat7-maven-plugin:2.0:deploy (default-cli) @ employee <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.0:deploy (default-cli) @ employee ---
[INFO] Deploying war to http://127.0.0.1:8080/employee-list
Uploading: http://127.0.0.1:8080/employee-list/deploy?path=%2Femployee-list
Uploaded: http://127.0.0.1:8080/employee-list/deploy?path=%2Femployee-list (27914 KB at 8258.5 KB/sec)
[INFO] tomcatManager status code:404, ReasonPhrase:Not Found
[INFO] <html><head><title>Apache Tomcat/7.0.28 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.28</h3></body></html>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.686s
[INFO] Finished at: Wed Jan 23 22:03:27 EET 2013
在localhost_access_log中的我得到这一行:
127.0.0.1 - - [23/Jan/2013:22:03:23 +0200] "PUT /employee-list/deploy?path=%2Femployee-list HTTP/1.1" 404 952
在tomcat7-stdout我得到:
янв 23, 2013 9:44:23 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at jndi:/localhost/employee-list/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: jndi:/localhost/employee-list/WEB-INF/web.xml; lineNumber: 25; columnNumber: 15; Error at (25, 15) : org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2719)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1054)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
...
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1770)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:855)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:201)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1051)
... 46 more
янв 23, 2013 9:44:23 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Occurred at line 25 column 15
янв 23, 2013 9:44:23 PM org.apache.catalina.startup.ContextConfig configureStart
SEVERE: Marking this application unavailable due to previous error(s)
янв 23, 2013 9:44:23 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
янв 23, 2013 9:44:23 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/employee-list] startup failed due to previous errors
有人可以告诉我哪里出错吗?
line25在bean的末尾:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>