I'm getting a 404 error when trying to access a servlet. After trying several solutions I found listed in past forum posts (and cleaning up the way I mapped the servlet), I'm still not able to get it to show up. I'm using Tomcat 6.0.18 on Ubuntu, and have deployed the app into the following directory structure:
I verified that the entryServlet.class file exists, and have set up my web.xml file as such:
I've tried http://localhost:8080/entry, http://localhost:8080/apps/hr/previsor/entry, and http://localhost:8080/hr/previsor/entry. Our makefiles delete the class files and remake them each time I run our distro script, at which point I check for compile errors and get none. Also, I see a fresh class file each time.
I grepped all the Tomcat logs. I find no error messages in any of them, except localhost_access_log, which shows requests for each URL I type, and a 404 error. For example, typing "http://localhost:8180/entry" results in "GET /entry HTTP/1.1" 404 970, which I would expect means it's reading the servlet mapping as absolute from the ROOT directory in Tomcat. I was under the impression that if I define a servlet mapping in a web.xml file inside the WEB-INF folder of a context, it would treat the top level of the context as the root for the purpose of reading definitions inside web.xml. If this is the case, then by my way of reasoning, the GET request should show "/entry" where / denotes the web root. I also tried changing the encoding type, to no avail. Is there something else I can try, or a glaring error I'm not catching?
OK, I see what you mean. In the future, I'm going to start using that layout whenever possible. For this instance, I would do that, but the only problem is that I have to put this in as a sub-directory of the ROOT dir, since this is an app that gets accessed through a web portal with security features. One of the big reasons is that our permissions schema populates a menu of apps which a user can access. While I realize that putting it in as a separate folder under the root dir would not keep the project from being accessed, our layout and backup schema are such that this would be difficult. The app which is housed in ROOT functions as the portal in which we invoke all of the different functionality in our "apps" folder, which is the individual app/web-tool repository.
As one of my teachers would say, "That's a reason, not an excuse." Why I have yet to fix this design is that we're pressed for time on our projects at my job, so the time it would take to redesign this whole system is having to be spread out over "whenever we can," which is a slow process.
I'm going to look into the App Manager and start working with that for my own projects outside of work. Is there a FAQ you could suggest which would expand upon the idea I can also map a context separately so that you can place it anywhere?
I don't understand your portal issues, but that doesn't matter as you can't create a web app inside another web app. You either replace ROOT with your web app, or you create a separate one. There's no in-between.
If you want it to be a separate app from ROOT then it needs to be directly under the webapps directory.
If it needs to be part of the ROOT app then do away with your WEB-INF directory and add your servlets to the ROOT app.
As Bear mentioned, the Tomcat manager app will show you which apps have been deployed and whether they're up and running or not.
Ben: I think your second suggestion is the best way for me to set this up. Thanks to both you and Bear for the clarification.
Bear: I've been going through the Tomcat Manager docs, and I notice that my test environment (which is running 6.0.18) is completely missing. Is it possible to delete that entire part of Tomcat without messing up the whole server?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop