应用程序已成功部署在Tomcat上,但出现404错误 [英] Application successfully deployed on Tomcat, but 404 error
问题描述
经过一番努力,我已经在(远程)Tomcat 5.5服务器(Turnkey Linux随附)上部署了一个Web应用程序.这是一个带有Java后端的GoogleWebToolkit网络应用.
I've deployed, after some struggle, a web-app on a (remote) Tomcat 5.5 server (Turnkey Linux comes with that). It is a GoogleWebToolkit web-app with a Java backend.
观察日志,一切正常./manager应用程序还在我的新应用程序上显示"running = true".
Observing the logs everything went fine. The /manager app also shows 'running=true' on my new app.
但是问题是,转到/myApp网址会显示404.到目前为止,我所做的没有成功:
But the problem is, going to the /myApp url gives 404. What I've done so far, to no success:
- 确保它确实是使用Eclipse在本地运行的,在那可以正常工作
- 检查了部署服务器上的日志,它成功加载了Spring和其他一些库.实际上,它显示的消息与我在Eclipse中以托管模式运行它时所显示的消息相同.
- /manager,/host-manager,/admin应用程序运行正常.
- 在/manager上重新加载应用程序也显示确定"
- 我指定了一个欢迎文件,该文件实际上在那儿,直接点击该文件还会显示404
- 我使用默认主机("localhost"),就像/manager,/host-manager和/admin应用一样
- 在互联网上进行了大量搜索,无济于事.
- 尝试使用另一台Tomcat(v6)服务器(我的家用ubuntu盒,我要部署的服务器是网络上的某个VPS),并且该服务器可以正常工作...重新安装VPS?
关于如何解决此问题的任何提示,找出问题所在或可能导致此问题的原因?会有冲突吗?$ CATALINA_HOME/webapps目录中有另一个应用程序正在运行,是否可以与部署在同一目录中的myApp冲突?
Any hints on how to fix this, find out what the problem is, or what might cause this? Can there be conflicts? there is another app running in the $CATALINA_HOME/webapps dir, can that conflict with myApp, which is in the same directory deployed?
下面是我的server.xml
Below is my server.xml
<?xml version="1.0" encoding="UTF-8"?>
<Server>
<Listener className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<GlobalNamingResources>
<Environment
name="simpleValue"
type="java.lang.Integer"
value="30"/>
<Resource
auth="Container"
description="User database that can be updated and saved"
name="UserDatabase"
type="org.apache.catalina.UserDatabase"
pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
</GlobalNamingResources>
<Service
name="Catalina">
<Connector
port="8009"
redirectPort="8443"
address="127.0.0.1"
protocol="AJP/1.3">
</Connector>
<Engine
defaultHost="localhost"
name="Catalina">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
<Host
appBase="webapps"
name="localhost">
</Host>
</Engine>
</Service>
</Server>
推荐答案
因此,您有一个位于Tomcat前面的Apache实例.对Apache的一些/所有请求都转发到Tomcat AJP端口8009.假设此Apache-Tomcat桥正常运行,因此仅关注已部署的应用程序,则可能需要在Apache的应用程序中添加一些 JKMount
指令. httpd.conf
文件,以确保确实将对/myApp
url的请求转发给Tomcat.否则,它们将由Apache提供服务,这意味着当找不到这些资源时,您会收到404错误.
So you have an Apache instance sitting in front of Tomcat. Some/all requests to Apache are forwarded to Tomcat AJP port 8009. Assuming this Apache-Tomcat bridge is working ok, and thus focusing only on your deployed application, you probably need to add some JKMount
directives into Apache's httpd.conf
file, to ensure that requests to /myApp
url are indeed forwarded to Tomcat. Otherwise, they are served by Apache, which means that you get a 404 error when those resources are not found.
这篇关于应用程序已成功部署在Tomcat上,但出现404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!