GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes The famous Chapter 3 problem in HFSJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "The famous Chapter 3 problem in HFSJ" Watch "The famous Chapter 3 problem in HFSJ" New topic
Author

The famous Chapter 3 problem in HFSJ

Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
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

Joined: May 18, 2005
Posts: 356
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


SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The famous Chapter 3 problem in HFSJ