• 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

got stuck in running my first struts example. help

 
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 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does LoginAction compile and is the class file in /WEB-INF/classes/coreapp/LoginAction?
 
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
Yes LoginAction compiles and the class is in
WEB-INF/classes/coreappl/LoginAction.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try the examples from the JavaRanch journal?
reply
    Bookmark Topic Watch Topic
  • New Topic