File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes getting ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "getting ClassNotFoundException" Watch "getting ClassNotFoundException" New topic

getting ClassNotFoundException

sonali rao
Ranch Hand

Joined: Nov 03, 2003
Posts: 64
Please go through my source code and let me know the what has gone wrong.
Following is struts-config.xml
<action path="/register1"
<forward name="success"

<message-resources parameter="resources.application"

Following is register1.jsp
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<HEAD><TITLE>New Account Registration</TITLE></HEAD>
<H1>New Account Registration</H1>
<form action="" method="POST">
<bean:message key=""/>
<input type="text" name="email"/><BR>
<bean:message key="form.password"/>
<input type="password" name="password"/><BR>
<input type="submit" value="Signup" />
Following is [ 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 {

Following is result1.jsp
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<H1><bean:message key="form.register.successful"/></H1>
(Version 1)
Following is what i set in the classpath.
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 path="/register1" type="coreservlets.RegisterAction1">
should read
<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
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
Ranch Hand

Joined: Jan 24, 2004
Posts: 184
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.
I agree. Here's the link:
subject: getting ClassNotFoundException
It's not a secret anymore!