Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The famous Chapter 3 problem in HFSJ

 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While running the application I get error 500 - java.lang.NoClassDefFoundError: com/example/web/BeerSelect (wrong name: BeerSelect).

The class file is present in C:\tomcat\webapps\Beer-v1\WEB-INF\classes\com\example\web.

My web.xml file is having the following entry.
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

Then why the error ?
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go to path C:\tomcat\webapps\Beer-v1\WEB-INF\classes and give the following command to compile the servlet

javac -d . com/example/web/BeerSelect/BeerSelect.java

pls check to see if the servlet-mapping is done properly

hope it helps
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

I compiled using the following command.

C:\Poornah\Jsp\MyPreparation\ch03\beerV1>javac -classpath C:\tomcat\common\lib\servlet-api.jar -d classes src/com/example/web/BeerSelect.java

My web.xml is as given in page 77. There is no change.

Actually, the book gives a slightly different command for compiling, which
I have not used. After servlet-api.jar, ':classes:.' is also to be used,
as per the book. If I use the same command, javac fails to recognise the
import command. Hence I modified it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic