应用程序成功部署在Tomcat上,但出现404错误

发布于 2024-10-07 02:23:20 字数 2136 浏览 8 评论 0原文

经过一番努力,我在(远程)Tomcat 5.5 服务器(Turnkey Linux 附带)上部署了一个 Web 应用程序。它是一个带有 Java 后端的 GoogleWebToolkit Web 应用程序。

观察日志一切都很顺利。 /manager 应用程序还在我的新应用程序上显示“running=true”。

但问题是,访问 /myApp url 会出现 404。到目前为止我所做的一切都没有成功:

  • 确保它确实使用 Eclipse 在本地运行,在那里工作正常
  • 检查了部署服务器上的日志,它成功加载了 Spring ,以及其他一些库。事实上,它显示的消息与我在 Eclipse 中以托管模式运行它时显示的消息相同
  • 。 /manager、/host-manager、/admin 应用程序运行良好。
  • 在 /manager 上重新加载应用程序也会显示“确定”
  • ,我指定了一个欢迎文件,该文件实际存在,直接点击该文件也会给出 404
  • 我使用默认主机('localhost'),就像 /manager、/host- manager 和 /admin apps
  • 在互联网上进行了大量搜索,但无济于事。
  • 尝试了不同的 Tomcat (v6) 服务器(我家的 ubuntu 机器,我想要部署的服务器是网络上某处的 VPS),它就可以正常工作......重新安装 VPS?

有关如何解决此问题、找出问题所在或可能导致此问题的任何提示? 会不会有冲突? $CATALINA_HOME/webapps 目录中正在运行另一个应用程序,这会与部署在同一目录中的 myApp 冲突吗?

下面是我的 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>

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.

Observing the logs everything went fine. The /manager app also shows 'running=true' on my new app.

But the problem is, going to the /myApp url gives 404. What I've done so far, to no success:

  • Made sure it does run locally using Eclipse, works fine there
  • Checked the logs on the deployment server, it successfully loads Spring, and some other libraries. In fact, it shows the same messages as when I run it in hosted-mode in Eclipse
  • The /manager, /host-manager, /admin applications run fine.
  • Reloading the app on /manager also says 'OK'
  • I have a welcome file specified, one that is actually there, directly hitting that also gives 404
  • I use the default host ('localhost'), just like the /manager, /host-manager and /admin apps
  • Did a lot of searching on the internet, to no avail.
  • Tried a different Tomcat (v6) server (my home ubuntu box, the one I want to deploy on is a VPS somewhere on the net), and there it just works... Reinstall the VPS?

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?

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱冒险 2024-10-14 02:23:20

所以 Tomcat 前面有一个 Apache 实例。对 Apache 的部分/所有请求都会转发到 Tomcat AJP 端口 8009。假设此 Apache-Tomcat 桥工作正常,因此仅关注已部署的应用程序,您可能需要将一些 JKMount 指令添加到 Apache 的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.

甜味超标? 2024-10-14 02:23:20

HTTPD/conf.d 文件夹应包含各种 .conf 文件,其中包含有关配置的 Web 应用程序的条目。您可以创建新的 .conf 文件或将 ProxyPass 条目添加到现有的 conf 文件中。添加ProxyPass条目可以将收到的请求路由到tomcat。例如ProxyPass /myApp/ ajp://localhost:8009/myApp/
对于上面的示例,Tomcat 应该侦听 AJP 连接器端口 8009。

The HTTPD/conf.d folder should have various .conf files which contains entries regarding the web applications configured. Either you can create a new .conf file or add the ProxyPass entry to an existing conf file. Adding a ProxyPass entry can route the request received to the tomcat. e.g. ProxyPass /myApp/ ajp://localhost:8009/myApp/.
Tomcat should be listening on AJP Connector port 8009 for above example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文