This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
When i'm trying to run a servlet through command prompt i'm getting this error.
C:\tomcat6\webapps\HeadFirst\WEB-INF\classes\web>java BeerSelectAction Exception in thread "main" java.lang.NoClassDefFoundError: BeerSelectAction Caused by: java.lang.ClassNotFoundException: BeerSelectAction at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Here is my xml file: <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
srinivas pola: -------------------------------- When i'm trying to run a servlet through command prompt i'm getting this error
The servlet class file(after compiling it), should be in appropiate location where the server can identify it (eg: WebAppName/WEB-INF/classes/"packagename"). Then restart the server (if you are deploying as a web application(WAR file etc..) no need to restart,just deploy). Then access the servlet through your browser.
where have you put it? Post the exact path in the servlet in your Tomcat server.
You may create a empty folder(MyAPP) and create a WEB-INF folder in their and put your web.xml in to it, and create a sub folder called classes in WEB-INF and put the servlet class in there with the correct package heirarchy. Then copy hole MyApp folder in to Tomcat webapps folder. Then you may access your servlet from the browser by http://hostname ortnumber/MyApp/urlmappingtoyourservlet. Hope this helps.