• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Servlets + JSP error: requested resource (/Beer-v1/SelectBeer.do) is not available.  RSS feed

 
Billy Sclater
Ranch Hand
Posts: 145
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've seen this particular problem 'done to death' on this, and other forums. I've waded through lots of the threads but I'm still having no luck);

Can anybody help me out? I'm getting a 404 error and 'requested resource (/Beer-v1/SelectBeer.do) is not available.' when I run the following servlet:

Here's the html:



The xml:



and the servlet code:




Here is the deployment structure:

/var/lib/tomcat7/webapps/ROOT/Beer-v1/form.html

/var/lib/tomcat7/webapps/ROOT/Beer-v1/WEB-INF/web.xml

/var/lib/tomcat7/webapps/ROOT/Beer-v1/WEB-INF/classes/com/example/web/BeerSelect.class

I'm using tomcat7, here's what I've tried so far:

*Altering the code at the start of the xml file to a more recent version than mentioned in the book. (no effect)
*Moving the entire Beer-v1 folder and all it's contents to /var/lib/tomcat7/webapps/ (html not found)
*Trying to install tomcat 5.5 (couldn't get it to work)

Does anyone have any ideas?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The next thing I'd do is to set up and use the Tomcat Manager application to make sure that the web app is properly deployed.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do the Tomcat server logs suggest? Most of the time, with Tomcat a 404 indicates your web app is not deployed.
 
Billy Sclater
Ranch Hand
Posts: 145
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the localhost_access_log:



 
Billy Sclater
Ranch Hand
Posts: 145
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting, I put my root folder Beer-v1 in the /lib/var/tomcat7/web apps/ROOT/ folder.

The tomcat manager doesn't recognise it in there, it only recognises when I put the Beer-V1 folder directly in webapps. But when I do, it can't find 'form.html'.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does not belong under ROOT; it belongs under webapps.

Where did you put the html file?
 
Billy Sclater
Ranch Hand
Posts: 145
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear

Ok, I moved the whole thing to under 'webapps' and out of 'ROOT'.

The 'form.html' is in:

'/var/lib/tomcat7/webapps/Beer-v1'

I get this error message:

The requested resource (/Beer-v1/form.html) is not available.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billy Sclater wrote:@Bear

Ok, I moved the whole thing to under 'webapps' and out of 'ROOT'.

The 'form.html' is in:

'/var/lib/tomcat7/webapps/Beer-v1'

I get this error message:

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


Try clearing out the tomcat cache and restart Tomcat.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the Tomcat manager app like I suggested earlier?
 
Billy Sclater
Ranch Hand
Posts: 145
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, got it! It's finding form.html now! And the tomcat mangaer doesn't appear to be reporting anything unusual.....but......

I now get this:

exception-
javax.servlet.ServletException: Error instantiating servlet class com.example.web.BeerSelect

root cause-
java.lang.UnsupportedClassVersionError: com/example/web/BeerSelect : Unsupported major.minor version 51.0 (unable to load class com.example.web.BeerSelect)

when I click on the submit button on my html page!
 
Billy Sclater
Ranch Hand
Posts: 145
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm...I've just read that this could be because my class is compiled with Java SE7 and Tomcat 7 works with SE6...I'll recompile the class with 6 and see what happens...
 
Billy Sclater
Ranch Hand
Posts: 145
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok! That fixed it! I just re-compiled with JavaSE6 and it's running smoothly now!

I forgot to mention that I also changed the web.xml file. The book uses tomcat 5, and the 'bit of code at the top of the file' reflects that. Here is the original web.xml:



I used the xml code from the web.xml file that came with tomcat7. I took the 'few lines at the top of the file', and replaced the first version. Here is the new (working) web.xml:



Anyway, thanks for your help!

I can go and get some sleep now!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!