| Author |
getting ClassNotFoundException
|
sonali rao
Ranch Hand
Joined: Nov 03, 2003
Posts: 64
|
|
Hi Please go through my source code and let me know the what has gone wrong. Following is struts-config.xml <struts-config> <action-mappings> <action path="/register1" type="coreservlets.RegisterAction1" > <forward name="success" path="/result1.jsp"/> </action> </action-mappings> <message-resources parameter="resources.application" null="false"/> </struts-config> Following is register1.jsp <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <HTML> <HEAD><TITLE>New Account Registration</TITLE></HEAD> <BODY BGCOLOR="#FDF5E6"> <CENTER> <H1>New Account Registration</H1> <form action="register1.do" method="POST"> <bean:message key="form.email"/> <input type="text" name="email"/><BR> <bean:message key="form.password"/> <input type="password" name="password"/><BR> <input type="submit" value="Signup" /> </form> </CENTER> </BODY></HTML> Following is RegisterAction1.java [ I kept it under classes/coreservlets dir] package coreservlets; import javax.servlet.http.*; import org.apache.struts.action.*; public class RegisterAction1 extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { return(mapping.findForward("success")); } } Following is result1.jsp <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <HTML> <HEAD><TITLE>Success</TITLE></HEAD> <BODY BGCOLOR="#FDF5E6"> <CENTER> <H1><bean:message key="form.register.successful"/></H1> (Version 1) </CENTER> </BODY></HTML> Following is what i set in the classpath. .;C:\jakarta-tomcat-4.1.29\common\lib\servlet.jar;C:\jakarta-tomcat-4.1.29\webapps\myproject\WEB-INF\classes;C:\jakarta-struts-1.1\lib\struts.jar I have struts.jar present in lib dir also. I am getting the following error in the tomcat server. No action instance for path /register1 could be created. java.lang.ClassNotFoundException: coreservlets.RegisterAction1 I get the following message in the browser. The server encountered an internal error (No action instance for path /register1 could be created) that prevented it from fulfilling this request. [ March 30, 2004: Message edited by: sonali rao ] [ March 30, 2004: Message edited by: sonali rao ]
|
 |
Roger Gazdzicki
Ranch Hand
Joined: Oct 04, 2002
Posts: 47
|
|
<action-mappings> <action path="/register1" type="coreservlets.RegisterAction1"> should read <action-mappings> <action path="/register1" type="coreservlets.RegisterAction1" />
|
Roger G<br /> <br />Anybody who tries to make anything idiot proof has obviously underestimated the intelligence of an idiot.
|
 |
sonali rao
Ranch Hand
Joined: Nov 03, 2003
Posts: 64
|
|
To Roger Garner What you have said is incorrect. struts-config.xml structure is something like this. <action path="" type=""> <forward name="" path="" /> </action> ----->action tag ends here. Anyways i am still stuck with my ClassNotFoundException. any idea?
|
 |
Srikanth Shenoy
author
Ranch Hand
Joined: Jan 24, 2004
Posts: 184
|
|
Sonali, What you have to do to get this straightened is this: 1)Remove those WEB-INF\classes and struts.jar from the classpath 2)Create a WAR or WAR like exploded directory structure with WEB-INF and lib sub directories. Put all your application related classes and jars there. 3)Always maintain a single copy of each jars. Never put your web application jars in the system classpath. That will solve the infamous class notfound exception. [ March 30, 2004: Message edited by: Srikanth Shenoy ]
|
Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
|
 |
sonali rao
Ranch Hand
Joined: Nov 03, 2003
Posts: 64
|
|
|
I modified my classpath by removing struts.jar and WEB-INF/classes from the classpath but it dint solve my problem. I still get the ClassNotFoundException.
|
 |
 |
|
|
subject: getting ClassNotFoundException
|
|
|