File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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

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-name>Ch3 Beer</servlet-name>

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/

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/

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.
subject: The famous Chapter 3 problem in HFSJ
Similar Threads
Tomcat doesn't find sevlet I know is there
javax.servlet.ServletException: Error allocating a servlet instance with Tomcat 6.0.20 on windows 7
Starting out on Servlets - from Head First Servlets and JSP
web security : doubt
Servlet Compilation