aspose file tools *
The moose likes Struts and the fly likes got stuck in running my first struts example. help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "got stuck in running my first struts example. help" Watch "got stuck in running my first struts example. help" New topic
Author

got stuck in running my first struts example. help

sonali rao
Ranch Hand

Joined: Nov 03, 2003
Posts: 64
Hi again
I am trying since 2 days to get rid of the ClassNotFoundException and implemented the advice which i got from a couple of people in this site but that dint solve my problem.
I have struts.jar placed in lib dir and not in classpath.
I am able to run successfully the examples which i get with struts documentation. does this mean that my classpath is set correctly and something is going wrong with the code in my application.
Following is the code of the appl which i am trying to run.
following is the partial code of web.xml
<web-app>
<display-name>Struts Blank Application</display-name>

<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
following is the code of struts-config.xml
<struts-config>
<action-mappings>
<action path="/register"
type="coreappl.LoginAction">
<forward name="success"
path="/result.jsp"/>
</action>
</action-mappings>
</struts-config>
following is the code of LoginAction.java
package coreappl;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return(mapping.findForward("success"));
}
}

following is the code of Login.jsp
<!DOCTYPE ...>
<HTML>
<HEAD><TITLE>New Account Registration</TITLE></HEAD>
<BODY BGCOLOR="#FDF5E6">
<CENTER>
<H1>New Account Registration</H1>
<FORM ACTION="register.do" METHOD="POST">
Email address: <INPUT TYPE="TEXT" NAME="email"><BR>

<INPUT TYPE="SUBMIT" VALUE="Sign Me Up!">
</FORM>
</CENTER>
</BODY></HTML>

following is the code of result.jsp
<html>
<head> </head>
<body>
<h1> Login Successful </h1>
</body>
</html>
I get the following error in tomcat
No action instance for path /register could be created
java.lang.ClassNotFoundException: coreappl.LoginAction
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31119
    
166

Does LoginAction compile and is the class file in /WEB-INF/classes/coreapp/LoginAction?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
sonali rao
Ranch Hand

Joined: Nov 03, 2003
Posts: 64
Yes LoginAction compiles and the class is in
WEB-INF/classes/coreappl/LoginAction.
M Miller
Greenhorn

Joined: Mar 02, 2004
Posts: 8
If you are a newbie to struts (like me) try this example to learn from.

Struts Tutorial that is found on the Struts website:
http://jakarta.apache.org/struts/resources/tutorials.html
There is an error with one of the examples that will cause an error. Look here how to solve the problem. Hope that helps!
http://www.tek-tips.com/gviewthread.cfm/lev2/3/lev3/13/pid/877/qid/685458
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Did you try the examples from the JavaRanch journal?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: got stuck in running my first struts example. help