Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError in Servlets  RSS feed

 
Vishwanath Shrivastava
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am getting NoClassDefFoundError,whenever I try to call my servlet class.
The error which is get is
"java.lang.NoClassDefFoundError: com/example/web/BeerSelect (wrong name: BeerSelect)".

I am trying the example given in "Head First Servlets and JSP". Application is nothing but a form and from a drop down box an option is selected and Submit button is hit. It calls my servlet. I don't know why am i getting this error.

Is there any problem with CLASSPATH or JAVA_HOME variable.
Please help.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you have compiled it incorrectly. It looks like you changed to the com/example/web/ directory and ran javac BeerSelect.java where you should be several levels up and run javac com/example/web/BeerSelect.java

If I remeber correctly (not having read the book) the instructions are quite explicit about where all the classes should be and how to compile the source, maybe read over this part again.

Dave
 
Vishwanath Shrivastava
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,

I appreciate for your reply.
Well I have compiled my BeerSelect.java correctly and got my class file.I have copied my class file to the following path:-
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\Beer-v1\WEB-INF\classes\com\example\web

But still it is not finding my class file.

Please help.

Thanks
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your class a servlet?
If yes, have you mapped your servlet in your deployment descritor?

I would also recommend to read that specific block of your book again.
Thanks.
 
Harish Madhavan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check you have correct package declaration in your java file ?

Harish
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!