• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

404 error on servlet due to "requested resource not available"

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
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?
 
Sheriff
Posts: 67553
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you placed the app in the wrong place.

If you want to create new web app, place the context folder of the app (the folder that contains WEB-INF) in Tomcat's webapps folder. Not in some hierarchy under ROOT, which is own web app.

You can also map a context separately so that you can place it anywhere, but that's a tad more complicated, so let's keep it easy for now.
 
Bear Bibeault
Sheriff
Posts: 67553
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, learn to use Tomcat App Manager tool so you can see what's been deployed and what hasn't.
 
Lou Umile
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear,
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?
 
Bear Bibeault
Sheriff
Posts: 67553
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java web apps aren't just a bunch of files.

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.
 
Lou Umile
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic