Forum Moderators: phranque
I place my html file in <CATALINA_HOME>\webapps\basic-servlet
and my java class in <CATALINA_HOME>\webapps\basic-servlet\WEB-INF\classes
I stop and start Tomcat and invoke the html. Does anyone know why I get a 404 error back with following message?
The requested resource (/basic-servlet/servlet/CurrencyConverter) is not available.
I started putting a copy of my class file CurrencyConverter just about every where and still no luck. Also, I do have my classpath set to include the Tomcat servlet.jar.
Well, I did get similar error messages with tomcat too.
Make sure that all your paths are ok and that all the right files are in the right sub directories.
What I recommend is start from scratch, making sure that your application is deployed exactly as it is on your local machine, using FTP.
Thats what I did and now our e-commerce application is running fine.
Good luck
in my HTML form I use the relative path
ACTION="servlet/CurrencyConverter"
So CurrencyConverter.class has been placed in <CATALINA_HOME>\webapps\basic-servlet\WEB-INF\classes (among other places). Shouldn't that work?
Directories are a pain, since there are essentially two paths in Tomcat - one for your actual files and classes, and the other to hold the compiled java classes to display.
For the default context, your classes would go:
<catalina-home>/webapps/ROOT/Web-inf/classes
any directories below this would be used for packages and beans.
Your JSP/HTML page would go in the ROOT folder.
Give that a try and see if it works.
and get a 404 error. Tomcat does not seem that complex to me, yet I'm having a heck of time getting a very basic app up and running. Before I get into deployment descriptors, I want to have basic example working first. Has anybody got Tomcat working without using a deployment descriptor?
Once you add a host, make sure that you either use invoker servlet or declare your servlet in web.xml otherwise tomcat won't know what to do with that url.
added:
About the html files, drop the ROOT part and check the logs. Tomcat is very verbose in describing what's going on once you start it.
If you create another folder at the same level of "ROOT" then you need to include it in your URL. You will also have to create a WEB-INF directory under that and a classes folder under that.
For now, get your default working properly, then expand from there.
My form displays and when the submit button is pressed it has <FORM METHOD=GET ACTION="servlet/CurrencyConverter">
No matter where I put the class CurrencyConverter, I get a 404 message back. I put the class in webapps\ROOT\WEB-INF\classes
and restarted Tomcat - no luck.
1. Does Tomcat automatically look for classes in folders WEB-INF\classes (i.e. in the ACTION call above, how does it know where to look?)
2. If I have my form in ROOT, should I change my ACTION to "http://localhost:8080/ROOT/servlet/CurrencyConverter"? (assuming question 1 holds true and it automatically looks in WEB-INF\classes)
If the java program does bomb, is there anyway to see why it died? Invoking the program in standalone does not work because it does not have a main method.
Tomcat is really tricky and even at times sneaky when it comes to class paths and file paths... that is where we got stuck the most. After a lot of trials and errors, we finally got the beast to work, but it was messy at times.
Once tomcat runs, you have the ball rolling. You will know all is ok when Tomcat brings you to a default-test page on the Tomcat / Apache web site that will tell you:
"If you see this page, it means your Tomcat app. server is properly configured". After seeing that, I guarantee you will have a big grin on your face... We did...
:-)
Hope that helps
I actually wrote SAMS publishing and they offered my money back - said the authir (Martin Bond) was not being responsive on this issue. I guess I'm not the first person to follow exactly what the book says and still not get it to work. Yet Tomcat does work. I don't know why I can't mine to call a simple servlet.
Tomcat 4.1\webapps\basic-servlet\WEB-INF\classes
it never worked. I also tried ROOT but same result.
When I loaded it into
Tomcat 4.1\webapps\examples\WEB-INF\classes it worked.
I don't think I configured it wrong because the log files do reference the basic-servlet folder. I'd like to get it working under basic-servlet though. Anybody have any suggestions?
Thanks so much for all the replies (I'm learning a lot though)