Application successfully deployed on Tomcat, but 404 error

Marten Sytema picture Marten Sytema · Dec 8, 2010 · Viewed 14.1k times · Source

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>

Answer

Tommi picture Tommi · Mar 30, 2011

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.