• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting ClassNotFoundException

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<action-mappings>
<action path="/register1" type="coreservlets.RegisterAction1">
should read
<action-mappings>
<action path="/register1" type="coreservlets.RegisterAction1" />
 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic