gpt4 book ai didi

java - 部署到 Tomcat 时出错 : tomcatManager status code:404, ReasonPhrase:Not Found

转载 作者:行者123 更新时间:2023-12-01 14:53:52 35 4
gpt4 key购买 nike

我在 this topic 创建 Spring 配置时遇到问题

现在我正在尝试使用 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 -etomcat7-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

第25行位于bean的末尾:

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

有人能告诉我哪里出了问题吗?

最佳答案

<url>配置为tomcat7-maven-plugin是 Tomcat 管理器 URL,而不是应用程序 URL:

<url>http://127.0.0.1:8080/manager/html</url>

另请参阅:

关于java - 部署到 Tomcat 时出错 : tomcatManager status code:404, ReasonPhrase:Not Found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14502447/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com