This week's book giveaway is in the Agile forum.
We're giving away four copies of Fixing your Scrum and have Ryan Ripley & Todd Miller on-line!
See this thread for details.
Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

NoClassDefFoundError in Servlets

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check you have correct package declaration in your java file ?

Harish
 
There's a way to do it better - find it. -Edison. A better tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic