aspose file tools*
The moose likes Servlets and the fly likes Wrapper cannot find servlet class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Wrapper cannot find servlet class " Watch "Wrapper cannot find servlet class " New topic
Author

Wrapper cannot find servlet class

surbhi tugnawat
Greenhorn

Joined: Mar 11, 2005
Posts: 5
Hi!!

I am new to servlets. I am trying to run an example from head first servlets(page 81). I have copied BeerSelect.class froma different location. Rest all is same as it says in the book.

Errors I am getting are

javax.servlet.ServletException: Wrapper cannot find servlet class com.example.web.BeerSelect or a class it depends on


java.lang.ClassNotFoundException: com.example.web.BeerSelect



Please help!!

Surbhi
surbhi tugnawat
Greenhorn

Joined: Mar 11, 2005
Posts: 5

I Start Tomcat by clicking start button on the Apache tomcat property window. Is it the right way of starting it???
http://localhost:8080 runs fine.

As I mentioned earlier I am having difficulties running the example in chapter 3 . I have my exapmle(Beer) in c:Tomcat/webapps/Beer

There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web.

When I run Tomcat I can open the form.html. This form instead of "Submit" button displays "Submit query"( Dont know why)
and when I pick the color from drop down and hit Submit query button.. i get Http Status 500 and above mentioned erros.

So thats my problem.
HELP!!!
Surbhi
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web

You mean you have BeerSelect.class in com/example/web don't you.

Don't worry about the 'Submit Query' thing, it's a HTML problem and not related to your issue. We can fix that later.
Manzar Zaidi
Ranch Hand

Joined: Oct 21, 2004
Posts: 43
Originally posted by surbhi tugnawat:
[QB]There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web.


Just wanted to ensure that it is down the three folder hierarchy com, example and web and not a single folder names com.eaxmple.web !

Also, the class should have the matching package declaration in the code..so do you have a package com.example.web; in the source code ?


SCJP 1.2, SCWCD 1.4.<br />What goes around comes around ... with ver 1.1
Manzar Zaidi
Ranch Hand

Joined: Oct 21, 2004
Posts: 43
Originally posted by surbhi tugnawat:
[QB]There I have a WEB-INF folder which has web.xml and classes folder and BeerSelect.class is in com.example.web.


Just wanted to ensure that it is down the three folder hierarchy com, example and web and not a single folder names com.eaxmple.web !

Also, the class should have the matching package declaration in the code..so do you have a package com.example.web; in the source code ?
surbhi tugnawat
Greenhorn

Joined: Mar 11, 2005
Posts: 5
yes BeerSelect.class is in WEB-INF/classes/com/example/web...and I also have the package statement in it.
Manzar Zaidi
Ranch Hand

Joined: Oct 21, 2004
Posts: 43
Originally posted by surbhi tugnawat:
javax.servlet.ServletException: Wrapper cannot find servlet class com.example.web.BeerSelect or a class it depends on


or a class it depends on
When you have the package set up properly and mapped correctly, it time we have to get into the code. Could you pleae paste the servlet code ?
And ... or a class it depends on..Please ensure that you have all the required libraries in the web-inf/lib folder.

The "Submit query" is the default message that shows up on submit button if you dont give it a name, so maybe your name element is missing or spelt wrong.
surbhi tugnawat
Greenhorn

Joined: Mar 11, 2005
Posts: 5
Hi

Here is my Servlet code

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException{

response.setContentType("text.html");
PrintWriter out =response.getWriter();
out.println("Beer selection advice <br>");
String c=request.getParameter("color");
out.println("<br> Got beer color " + c);

}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wrapper cannot find servlet class
 
Similar Threads
Head First Servlets program error
HF Servlet and Java - MVC tutorial
Can't find package
Compiling servlet version two code in HFSJ
Exercise from HF Servlets & JSP