File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes 404 error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "404 error" Watch "404 error" New topic
Author

404 error

Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
I am reading head first jsp 2nd edition. I am using tomcat 5.5 and java 1.6. I get the following error trying to do ch3.:

The requested resource (/Beer-v1/form.html) is not available

My directory structure is identical to that described in the text. Thank you.

on a related note, how do i shut down and start tomcat 5.5?
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
anyone got an update to my problem? I've seen other people have this problem but it was just a syntax error, I dont see any syntax errors.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Vulloff hatread wrote:I am reading head first jsp 2nd edition. I am using tomcat 5.5 and java 1.6.

Unrelated to your problem: why not the newest Tomcat, the Tomcat 6?


The requested resource (/Beer-v1/form.html) is not available

Either the URL is wrong (it is case sensitive!), or the resource is actually not there where you think it is.

on a related note, how do i shut down and start tomcat 5.5?

Tomcat is apparently already started. How did you start it then? :o)

It may be useful to go through the Tomcat documentation as well.
Here it is: http://tomcat.apache.org/tomcat-6.0-doc/index.html
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
I am using tomcat 5.5.27 instead of tomcat 6. There is a difference between 5.5, which the book uses and 5.5.27 since there is no startup.sh to start the web container.

Here is my directory structure:
dev environment:

My Projects
--->beerV1
---->etc
--->web.xml
---->lib
---->src
--->classes
--->web
---->form.html

deployment environment:

--->tomcat home
--->webapps
--->Beer-v1
--->WEB-INF
---->web.xml
--->form.html

My web.xml:
<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>

<!-- Fully qualified name of the servlet class file -->
<servlet-class>com.example.web.BeerSelect<servlet-class>
</servlet>

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

</web-app>

How do I preserve whitespace in theses posts?
the web.xml is under WEB-INF and etc.

form.html is under web and Beer-v1.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I am using tomcat 5.5.27 instead of tomcat 6.

Then read the Tomcat 5.5 documentation.
http://tomcat.apache.org/tomcat-5.5-doc/index.html

How do I preserve whitespace in theses posts?

You can use the [tt] tag for preformatted text and the [code] tag for code blocks.

Regarding to your problem, your directory structure is unclear. Why does the project directory look different from the deployed directory? Naming differs a lot and casing also!
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
dev: beerV1-->web-->form.html
beerV1-->etc-->web.xml
deployment: tomcat home-->webapps-->Beer-v1-->form.html
tomcat home-->webapps-->WEB-INF-->web.xml

Because that is what the book specified on pages 72 and 73. I think the problem is from the web.xml header.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The WEB-INF belongs in a webapp, not in the root deployment folder.
Both the structures ought to be exactly the same. There is no need to mess/change it.

You have a Beer-V1 root directory.
In the Beer-V1 directory you should have the WEB-INF directory and the web files (jsp, html, css, js, etc, such as form.html).
In the WEB-INF directory you should have the web.xml file.
In the WEB-INF directory you should have the classes directory with there in all packages/classes.

That Beer-V1 root directory is then to be placed in the webapps directory of the appserver. After a restart of the appserver it should be accessible the usual way.
Hector Tenedero
Ranch Hand

Joined: Oct 13, 2008
Posts: 31
What's your welcome file?

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
By the way, do you actually read the book? I don't have the book right now, but I can't believe that it is explained that bad way.
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
I determined what the problem was; Beer-v1 needs to be in the ROOT folder. This is an error in the book since they tell you to put it in the webapps folder.

Now I am getting the same problem for the selectBeer.do uri. I am disappointed that the editors didn't test the examples before publishing the book.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

If Beer-v1 contains a WEB-INF folder, then it is not correct to put it in the ROOT folder, and the webapps folder is correct.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lasanka Weerawansa
Greenhorn

Joined: Jun 30, 2005
Posts: 2
If your resources are placed as something like below it should work, you must not put your project inside ROOT directory

tomcat home
 |
 |->webapps
 |      |
 |      |->Beer-v1
 |      |     |
 |      |     |->form.html
 |      |     |
 |      |     |->WEB-INF
 |      |     |       |
 |      |     |       |-> web.xml

In that case your URL (e.g. http://localhost:8080/Beer-v1/form.html) should work

Check following things too
1) Whether you have misspelled anything in your url (e.g. if you type beer-v1 it will not work)
2) Whether you have placed form.html inside WEB-INF
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
Bear Bibeault wrote:If Beer-v1 contains a WEB-INF folder, then it is not correct to put it in the ROOT folder, and the webapps folder is correct.


My environments can be shown here:
http://books.google.com/books?id=15wp6fmAy4sC&pg=PR11&dq=head+first+servlets+and+jsp+2nd+edition+page+72#PPA73,M1


I installed Tomcat 5.5.27 and java 1.6_02.

The environments shown on pages 72 and 73 in the link above did not work for me, when going to: http://localhost:8080/form.html I get "The requested resource () is not available." Strangely enough when I put Beer-v1 in ROOT I can see form. UNFORTUNATELY, I get the resource not found error on SelectBeer.do after that! Can someone please tell me what is going on I have spent hours reading and reinstalling to no avail.

Trying to start Beer-v1 in tomcat manager gives: FAIL - Application at context path /Beer-v1 could not be started
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Bauke Scholtz wrote:By the way, do you actually read the book? I don't have the book right now, but I can't believe that it is explained that bad way.


Yes it is pretty bad!! Head First Servlets JSP is my favorite book - no doubt. But really the messy directory structure (different for source and deployment) - an absolute mess for first timer - The first time I tried deploying on tomcat took me 4 hours.

@ Vulloff - My advice is start again. The way the source code is arranged does not matter at all. Just make sure all your deployments are correct. I'll try and give you steps to check if its working.

1. Get Rid of anything you have created in the Root folder. You not supposed to know that such a folder exists - All you need to bother about is the wep-apps folder.

2. Follow Lasanka advice of creating the deployment structure - This step is really important - so be careful. Doesn't matter if you think you have done it before. Do it once again.

3. Make sure that you create the WEB-INF directory inside Beer-v1 - on tomcat this is a major source of problem. If you don't create the WEB-INF directory Tomcat does not complain but the application does not work either.

4. For good measure put the web.xml file inside the WEB-INF directory - the header contents really don't matter - at least to start with.

5. Re-Start you web server. Make sure the server is up by typing,
a. http://localhost:8080/ - Should show the Tomcat home page

6. Now try http://localhost:8080/form.html. Your HTML form should open.

7. If you still face a problem - let us know which step does not work for you!

HTH!


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
I have:

1. uninstalled tomcat 5.5.27 and restarted my computer.
2. installed tomcat 5.5.27 using the windows service installer.
3. went to C:\program files\Apache Software Foundation\Tomcat5.5\webapps:
a. created a directory called Beer-v1 which contains
i) form.html
ii) a directory titled WEB-INF, which contains
1. web.xml
2. a directory called classes
3. a directory called lib
4. The contents of web.xml:
<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>
5. typed in http://localhost:8080 and see the welcome to tomcat screen
6. typed in http://localhost:8080/Beer-v1/form.html and see "The requested resource () is not available."
7. typed in http://localhost:8080/form.html and see "The requested resource (/form.html) is not available."

To reiterate:
My deployment environment looks like page 73 of that link I posted earlier.
I am using Tomcat 5.5.27 and java 1.6_02

Sam, did you say you used the same directory structure as Lakshama posted(identical to the book's) and it worked?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

a. created a directory called Beer-v1 which contains

Sigh. This should be created in the webapps folder. Not ROOT. Not anywhere else. It's really not that hard.
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
Bear Bibeault wrote:
a. created a directory called Beer-v1 which contains

Sigh. This should be created in the webapps folder. Not ROOT. Not anywhere else. It's really not that hard.


Beer-v1 is in webapps. webapps has ROOT and Beer-v1.
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Your setup looks perfectly correct no problems there. So we will have to look for other common problems (This might be hard!)

1. Goto C:\program files\Apache Software Foundation\Tomcat5.5\webapps\Beer-v1\form.html and just double click on form.html - does it open up in IE (or whatever your default browser is?)

2. Hit the following two URL and let us know the message you get,
a. http://localhost:8080/Beer-v1/
b. http://localhost:8080/Beer-v1/SelectBeer.do

3. Finally just check this - open a explorer window (win+E) --> goto tools --> folder option --> view --> uncheck the option for 'hide extensions for know file types'. Have a look at C:\program files\Apache Software Foundation\Tomcat5.5\webapps\Beer-v1\form.html -- does it read form.html.txt by any chance?

First deployments are really tough -- don't worry it will work out -- your definitely on the right track.

And yes the deployment structure posted by Lakshama posted(identical to the book's, same as yours) is definitely the correct one!

Let us know what happens.
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
I'm not sure if I restarted tomcat properly. Tomcat 5.5.27 does not have start/shutdown scripts in the bin directory. I went to the tomcat manager, saw the /Beer-v1 application was already off and clicked start. After clicking start I see "FAIL - Application at context path /Beer-v1 could not be started". I still clicked on the links you asked me to:

Clicking on 2.a. I see The requested resource () is not available.
Clicking on 2.b I see The requested resource () is not available.(I copied SelectBeer.class into %TOMCAT_HOME%\webapps\Beer-v1\WEB-INF\classes\com\example\web.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Vulloff hatread wrote:Tomcat 5.5.27 does not have start/shutdown scripts in the bin directory.
Why not? have you deleted them? Why?

I went to the tomcat manager, saw the /Beer-v1 application was already off and clicked start. After clicking start I see "FAIL - Application at context path /Beer-v1 could not be started". I still clicked on the links you asked me to:

If the application hasn't started, of course you can't access it. Look into the logs to find out why the application is not starting.
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Vulloff,

I was looking at your web.xml file and looks like you have got it wrong.

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

The end tag for the <servlet-class> is not correct. You original post had the correct closing tag!
Just check out your web.xml again.

Also as Bear Suggested look at your log files in case the problem still continues. Look at the log file --> %TomcatHome%/log/catalina.<today's data>.log
Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
I did not delete them. Download tomcat 5.5.27 for yourself and you can see they are not in there.

Mar 26, 2009 8:32:15 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 8 column 46: The element type "servlet-class" must be terminated by the matching end-tag "</servlet-class>".
org.xml.sax.SAXParseException: The element type "servlet-class" must be terminated by the matching end-tag "</servlet-class>".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1562)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:348)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1048)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1173)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:549)
at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:105)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
Mar 26, 2009 8:32:15 PM org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Parse error in application web.xml file at jndi:/localhost/Beer-v1/WEB-INF/web.xml
org.xml.sax.SAXParseException: The element type "servlet-class" must be terminated by the matching end-tag "</servlet-class>".
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1562)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:348)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1048)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1173)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:549)
at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:105)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
Mar 26, 2009 8:32:15 PM org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Occurred at line 8 column 46
Mar 26, 2009 8:32:15 PM org.apache.catalina.startup.ContextConfig start
SEVERE: Marking this application unavailable due to previous error(s)
Mar 26, 2009 8:32:15 PM org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
Mar 26, 2009 8:32:15 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Beer-v1] startup failed due to previous errors

The logs say the "servlet-class" tag is not closed properly. I never wrote any file with the tag "servlet-class". My web.xml file:
<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>
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Read My post above ...
Fan Feng
Greenhorn

Joined: Aug 13, 2009
Posts: 1
I don't know whether you guys figured it out
I got the same question and I found out the <web-app> tag in web.xml is a little bit different than the ones in build-in examples
then I copied and pasted it and it works now

Seymour Knecht
Greenhorn

Joined: Aug 27, 2009
Posts: 1
I am a 11-hour veteran of Tomcat 6.
As a 40-minute veteran, I had a problem with this too, due to a misreading of the Tomcat default home page.

"This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat6/webapps/ROOT/index.html
Tomcat6 veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in /usr/share/tomcat6 and CATALINA_BASE in /var/lib/tomcat6, following the rules from /usr/share/doc/tomcat6-common/RUNNING.txt.gz."

By inspection, I found a copy of the index.html at /usr/share/tomcat/webapps/default-root/index.html. I therefore built the deployment hierarchy in /usr/share/tomcat/webapps/ rather than in /var/lib//tomcat/webapps. Once I copied the directory from/usr/share/tomcat/webapps/ to /var/lib//tomcat/webapps, everything worked.

Just in case anyone out there is as careless as me...

Regards,
SK.
Krzychu Montana
Greenhorn

Joined: Oct 17, 2009
Posts: 4
I figured out whats going on.
If you're using Firefox the name of your directory cant contain a dash. Rename "Beer-v1" to "Beerv1" and it will work just fine.
I guess thats why authors of the "Head First Servlets and JSP" book used IE for that! Because it works perfectly fine with a dash under Internet Explorer!!! It seemed dodgy the second i looked on the pic. Java/Unix developers use IE??? Now it adds up perfectly fine.

[not-so-nice portion of post removed]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Krzychu Montana wrote:If you're using Firefox the name of your directory cant contain a dash.

That didn't sound right to me, so I just checked and Firefox seems to have no issues at all with a context path containing a dash. So there must be something else at play to account for your results.

Also, please be aware that one of the principle guidelines here on the Ranch is "be nice". The not-so-nice portion of your post has been removed.

And, please do not post more than once. Your duplicate posts have also been removed.
Krzychu Montana
Greenhorn

Joined: Oct 17, 2009
Posts: 4
Sorry, but I simply posted my solution in the 3 threads where this problem was touched on. Its not flooding, spamming or whatever, its just spreading the solution
Also you gotta admit that looking for such a stupid bug for half a day can make you angry.
And because it doesnt apply in your case, maybe every other poster that brought this problem up could use my kind advice.
But still - using the IE by die-hard unix users seems suspicious to me
Cheers
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Krzychu Montana wrote: just spreading the solution
Again, post once.
Also you gotta admit that looking for such a stupid bug for half a day can make you angry.
I suggest refraining from posting when angry.
using the IE by die-hard unix users seems suspicious to me
Your conclusion that IE was used is unfounded.
Sarith Khlot
Greenhorn

Joined: Oct 19, 2009
Posts: 2
Guys, I read from the top to the bottom, and tried everything as you said, BUT IT STILL NOT WORK! what to do next?
pooja jain
greenhorn
Ranch Hand

Joined: Jan 12, 2005
Posts: 213
Sarith Khlot wrote:Guys, I read from the top to the bottom, and tried everything as you said, BUT IT STILL NOT WORK! what to do next?


i've not read the whole post.

are you able to see tomcat console???


:d
Anthony Donnelly
Greenhorn

Joined: Mar 24, 2009
Posts: 4
Hi Sarith,

Have you resolved your problem? If not, post your code and I can have a look. Bear in mind, of course, that I am new to servlets.

I too had this problem that plagued me for days. In the end it came down to using the wrong case when I created the directory structure under Tomcat.

I had webapps\Beer-v1\WEB-inf rather than webapps\Beer-v1\WEB-INF. Once I fixed that problem, it worked.

In my experience it doesn't matter:
- whether or not you have a space in the servlet name in web.xml, ie, <servlet-name>Ch3 Beer</servlet-name> is fine.
- whether or not you have a hyphen in your folder names, ie, Beer-v1 works fine.
- whether or not you use IE or Firefox.

If you have followed the directory structure outlined above by Vulloff hatread, then my guess is that there is a typo somewhere.

I hope this helps.

Good luck,
Anthony
Daniel Viggen Nelson
Greenhorn

Joined: Oct 28, 2009
Posts: 1
I found a solution that worked for me. As you might figure out, this error could be due to a lot of things. There fore I will list a couple of error reasons worth trying.

- Tomcat is not set with the correct Java version (1.5 or grater) even though this is pointed out during the installation of tomcat. Verify this by tomcat/bin/tomcat5ws.exe -> Java tab. If the class files is compiled with a 1.6 java and you try them out on a tomcat with an other java you will get a lot of exceptions thrown an strange hard to recognize server messages about that the /SelectBeer.do file could not be found.

- Your environment variables for CATALINA_HOME and JAVA_HOME might not be correct when launching tomcat. In the book you could read that you should start the server with startup.bat and shotdown.bat but they are not found anywhere in the tomcat5.5.28 distribution. The good thing is that they are distributed in the jakarta-tomcat-5.0.28. These bat files sets some environment variables along with setclasspath.bat and catalina.bat. There for copy them and use with your tomcat5.5.28 version. Then you should paste your app in /TOMCAT_HOME/webapps/Beer-v1/ and connect to that app with http://localhost:8080/Beer-v1/form.html

- On my computer using MS Vista SP2 return the old Java 1.4.2 when performing java –verison when JAVA_HOME was set up with Java 1.6 (the OS did return Java 1.6 when asking for version on javac). There for I uninstalled Java 1.4.2 and made sure I only got the Java 1.6 on my computer.

- Aslo note that the web.xml start tag should be



and that it is important to get the argument for request.getAttribute(“styles”) exactly the same that is requested in the BeerSelect class.

I will hope this will get you going or other encounter the similar problem.
Anthony Donnelly
Greenhorn

Joined: Mar 24, 2009
Posts: 4
Thank you Daniel.

If anybody has created their chapter 3 web.xml by cutting and pasting from the chapter 1 example, then they will find 2 errors in the start tags. These errors are corrected in the Head First Servlets & JSP errata: http://oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed.


[30] the first line of web.xml;
the first line of the web.xml file should be:
<?xml version="1.0" encoding="ISO-8859-1"?>

[30] Step 3 - within the xml code for the DD;
the third and fourth lines of xml read:

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
web-app_2_4.xsd"

This should be combined into one line, and a forward slash
should be inserted between the "j2ee" and the "web-app_2_4.xsd":

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"



This quote is specifically for chapter one, but it may help.
Sarith Khlot
Greenhorn

Joined: Oct 19, 2009
Posts: 2
Guys, thank you so much. I changed the folder name of Beer-v1 to whatever different, and now it works. I mean I created from scratch with different name, not Beer-v1 (i.e: test).
Anthony Donnelly
Greenhorn

Joined: Mar 24, 2009
Posts: 4
That's great Sarith. Yeah, sometimes with these examples, it's easier just to redo from scratch.
Serhat Duygun
Greenhorn

Joined: Jun 22, 2012
Posts: 7
i had the same problem at last i figured out problem
There are two steps to run the app with tomcat.
first step is the deploying, should be



Second step is the web.xml
i changed <web-app> tag as

its should be work after those two corrections.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 404 error