This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFS: Problem with deploying and testing Beer-v1 App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFS: Problem with deploying and testing Beer-v1 App" Watch "HFS: Problem with deploying and testing Beer-v1 App" New topic
Author

HFS: Problem with deploying and testing Beer-v1 App

SAIYED
Greenhorn

Joined: Dec 10, 2004
Posts: 9
I am very new to tomcat and trying to get my very first web application up and running. This is the web app from the book Head First Servlet and JSP named Beer-v1(Chapter 3: Hands on MVC)

Tomcat version: 5.0.28
Platform: Windos 2000
Problem:
I have following structure

c:\tomcat\webapps\Beer-v1\form.html
c:\tomcat\webapps\Beer-v1\WEB-INF\web.xml
c:\tomcat\webapps\Beer-v1\WEB-INF\classes\com\example\web\BeerSelect.class

When I start the tomcat service and try to run my web app via IE
http://localhost:8080/Beer-v1/form.html , it gives me resource could not be found error.
If while tomcat is running, I create another folder under webapps and copy my form.html there and invoke it via IE it works fine. But if I stop and restart the tomcat service this also stops working.

i even made a copy of one of example application that comes with tomcat, that also act the same.
I know, I am doing something wrong and not setting some configuration files.
Please help. It's stopping me from doing lots of handon and understaning key concepts.
Premkumar Gopal
Greenhorn

Joined: Jun 12, 2004
Posts: 22
Hi,
One of the reasons could be :
Trying to call doPost(...) instead of doGet(..). I suggest you have both methods and calling the one from other to test it out whether it is not the issue. If you figure out that is the issue, then you know why it is so(because HF says when doGet() / doPost() gets invoked).

Thanks


SCJP(1.4), OCP(8i) DBA, Websphere Certified Associate Developer, Websphere Certified Solution Developer, Websphere Portal Application Developer
SAIYED
Greenhorn

Joined: Dec 10, 2004
Posts: 9
I am using the post method in my form as mentioned in the example in Chapter 3
Here si the html for the form
---------------------------
<HTML>
<BODY>
<h1 aligh="center">Beer Selection</h1>
<form method="POST" action="SelectBeer.do">
Select Beer Characteristics<p>
Color:
<select name="color" size="1">
<option> light
<option> amber
<option> brown
<option> dark
</select>
<br><br>
<center>
<input type="submit">
</center>
</form>
</BODY>
</HTML>
Premkumar Gopal
Greenhorn

Joined: Jun 12, 2004
Posts: 22
Could you also post your deployment descriptor. Thanks
Patrik Nilsson
Ranch Hand

Joined: Oct 05, 2004
Posts: 49
I had a problem trying to do the same thing.
I renamed my Beer-v1 to Beer and everything worked for me.
I don't know if this is the problem for you but you can always give it a try!!


Sun Certified Java Programmer<br />Sun Certified Web Component Developer<br />IBM Certified Enterprise Developer
SAIYED
Greenhorn

Joined: Dec 10, 2004
Posts: 9
Since I am working on this at home, I do not have access to that very file but here I typed in what that file has. It is from HFS chapter 3 Handon MVC sample application. (I may have done a typo)

As i mentioned, when i made a copy of tomcat sample application jsp-examples and named it "b". it worked until i restarted my tomcat service.
The same problem i get with my sample application.
It almost like app is not getting auto deployed or getting some error and not getting deployed.( I can understand error in my app but copy is tomcat sample app should have everything right). So I am ruling out error theory. Now there could be a step in deployment i might be missing but i did exactly what they said in book.

-------------------------------------------------------------
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:/java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</select-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>
SAIYED
Greenhorn

Joined: Dec 10, 2004
Posts: 9
Thanks patrik, I did try renaming to remove the - but still the same issue.
If I start the tomcat and then copy form.html file under beer-v1 app it works fine until i stop and restart the tomcat.

I am assuming with so many people going through HFS they must have tried the sample app "hands on". then why it only me who it getting the error?
May be its only me who is so ignorant about tomcat working and setup.

Hey guys, please help!
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
1. What version of Tomcat are you running? (I have 5.0.28)
2. Access Tomcat Manager, using http://localhost:8080/manager/html. Enter the userid/password, if asked. (admin/admin is default)
3. Do you see /Beer-v1 in Tomcat Web Application Manager?
4. Stop /Beer-v1 (not Tomcat, just the web-application)
5. Try accessing http://localhost:8080/Beer-v1/form.html. (should fail!)
6. Start /Beer-v1, and access http://localhost:8080/Beer-v1/form.html (works???)
7. Please let us know the Server Information listed at the bottom of the http://localhost:8080/manager/html page.
SAIYED
Greenhorn

Joined: Dec 10, 2004
Posts: 9
Thanks for your help and insight into tomcat. tomcat Manager did help a lot. I was able to find out the problem and correct it. It is nice to know that your application is correctly deployed and running before accessing it via IE.
Thanks once more
 
Consider Paul's rocket mass heater.
 
subject: HFS: Problem with deploying and testing Beer-v1 App
 
Similar Threads
Tomcat WebApp Deployment
Problems with the Example from HF Servlets & JSP in Chapter 3
Question on BeerAdvice example
Deploying an app to Tomcat
Application not Available