• 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

Need help with java.lang.ClassNotFoundException: org.apache.struts.actions.ForwardAction

 
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying the struts hibernate integration example given at www.mkyong.com. Whenever i am trying to run the web application, i am getting this exception:


My struts-config.xml file is as follows:


Am I getting this exception because i am trying to access the same resource (add_customer.jsp) using different action paths /AddCustomerPage & /AddCustomer in the <action-mappings/>?

I am trying to redirect to the add_customer.jsp from my index.jsp page the code for which is as follows:

Where is the mistake? Where am I going wrong? Please help me.
Thank you.
 
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure about this, but have you tried using <html:link>? Once again, this is a wild guess...
 
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepaks Deshpande wrote:

Am I getting this exception because i am trying to access the same resource (add_customer.jsp) using different action paths /AddCustomerPage & /AddCustomer in the <action-mappings/>?

I am trying to redirect to the add_customer.jsp from my index.jsp page the code for which is as follows:


hai,I am not sure of my answer ,but i hope the following..
root cause is it is unable to load "ForwardAction" ,so please check whether you have added " struts-extras-(version).jar" in CLASSPATH? because ForwardAction is built-in Action class and the super class of this class is "org.apache.struts.action.Action" class .and more over the Forward action class is available in "org.apache.struts.actions' package inturn this pachkage is available in struts-extras-(version).jar .so please check this.

one more thing.. you stated:

I am trying to redirect to the add_customer.jsp from my index.jsp page



Generally speaking iit is a bad idea tp place within your jsp pages any direct links to other JSP pages.For one reasong it is not good design decision;the struts-config.xml which is the part of the Controller ,should contain the entire flow of your application.
In Model-View-Controller architecture ,it is the role of the Controller to select the next View.The Controller consits of struts configuration ,theActionServlet,and the actions.Tf you add a link directly to another jsp,,you are violating MVC 2 principles.. where one resource should not communicate with other resouce directly but only should by means of Controller (ActionServlet if struts 1.x - and FilterDispatcher if struts 2.x).and more over struts framework strictly follows MVC2 principles.
for this you need to use ForwardAction class(built-in).
The ForwardAction acts as bridge from currect View(JSp) and teh pages it link to.It uses RequestDispatcher to forward to a specified webresource.It allows you to link to a action insted of directly to jsp.Later,if you need you can theActionMapping in the struts configuration to to a custom one that you write instead of using ForwardAction that struts provide.


To use ForwardAction:

1)use the html:link tag with the action attribut ,add alink to the jsp page that points to the action.
2)Create an action mapping in the struts in the struts configuration file that uses the ForwardAction with the parameter attribute to specify the Jsp path...







 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Deepak..
I am just quoting an example.. if I am wrong please correct me...


suppose you have a jsp pagethat has a direct link to another jsp page;



you have converted to MVC2 architecture and you wanted to change the html:link to an action.,because you already have a link, so simple change it as follows:



and we need to remove the page attribute and add an action attribute that points to the home action. and create the home action mapping.


the ForwardAction uses the parameter attribute so that you can specify the path.,the paramter here is set to "/index.jsp",which was that page attributte of the html:link tag that was originally set to .Thus, the parameter attribute indicated to whether you want the ForwardAction to forwad..

please correct me if I am wrong...

 
Deepaks Deshpande
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Shwetha
Do you mean to say all the problem with this exception is being caused by the <c:redirect /> tag in the index.jsp page?
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please check the root cause.. ClassNotFoundException:ForwardAction.. when you use a built-in class, you need to add its corresponding package where the class is residing.. next try to change our code inorder to make it more effcient.... it work when you direclt link one jsp to another,, I am not saying that it doesn't but it is voilating MVC principle and to avoid that I think some where in that ForwardAction class is used and yo didnt add the corresponding package..
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Deepak..
please check this , I think you have used without setting the JAR file (struts-extras-(version).jar)

I am not sure of my answer ,please let me know ,so that I can learn and correct myself
 
reply
    Bookmark Topic Watch Topic
  • New Topic