This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line!
See this thread for details.
The moose likes Servlets and the fly likes javax.servlet.ServletException: Wrapper cannot find servlet class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "javax.servlet.ServletException: Wrapper cannot find servlet class" Watch "javax.servlet.ServletException: Wrapper cannot find servlet class" New topic
Author

javax.servlet.ServletException: Wrapper cannot find servlet class

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 795
Hello,

The following is my class code: the code don't have any error and class resides in package globalcategories.classes



my WEB-INF


When I ran servlet then its throwing following exception:


Thanks in anticipation

Best regards
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

The servlet-class element should have fully qualified class name of the servlet.

Also, put a default constructor explicitly since there is a custom constructor in the class.


Regards,
Prajakta
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 62585
    
  68

Prajakta Acharya wrote:Also, put a default constructor explicitly since there is a custom constructor in the class.


Why is there a constructor? Servlets should never have constructors.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 795
Hello,

I change WEB-INF as follow:


and now its giving following exception:



I removed constructor and its working fine now

Thanks again
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 795
Bear Bibeault wrote:
Prajakta Acharya wrote:Also, put a default constructor explicitly since there is a custom constructor in the class.


Why is there a constructor? Servlets should never have constructors.


You are very right

Thanks for favoring

Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

Oops.....yes, servlet shouldn't have a constructor at first place.
Sorry for that.

Just imagined what will be the next error once a fully qualified class is referred in web.xml.
Container will not be able to instantiate it and wrote that.

But yes, the constructor should not be there.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: javax.servlet.ServletException: Wrapper cannot find servlet class