| Author |
DispatchAction error .... NoClassDefFoundError...
|
Tokunbo Oke
Ranch Hand
Joined: Sep 09, 2003
Posts: 57
|
|
After adding DispatchAction functionality to my application I kept getting the error below, can anyone please tell me what is wrong. More importantly, have I implemented DispatchAction correctly? Thank you. NOTE: "on click" stands for onclick i.e without a space ERROR: ====== root cause ========== java.lang.NoClassDefFoundError: org/apache/struts/legacy/GenericDataSource at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:502) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1680) at ACTION CLASS: ============= package com.cargo.gen; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.DynaActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.DispatchAction; public class Customer extends DispatchAction { public ActionForward regCustomer(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { System.out.println("Register customer"); return mapping.findForward("success"); } public ActionForward updateCustomer(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { System.out.println("updateCustomer"); return mapping.findForward("success"); } } ACTION MAPPING: =============== <action path="/customer" type="com.cargo.gen.Customer" name="customerForm" scope="request" parameter="methodToExecute"> <forward name="success" path="/jsp/success.jsp"/> <forward name="failure" path="/jsp/failure.jsp"/> </action> JSP: ==== <%@ page language="java" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <html> <head> <title><bean:message key="fieldL.title" /></title> </head> <body> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> </tr> <tr> <td height="68" width="48%"> <div align="left"> <img src="file:///D|/Apps/Apache/Tomcat-4.1.27/webapps/employees/images/wxmainlogowhitespace.gif"> </div> </td> </tr> <tr> <td> </td> </tr> </table> <html:form action="/customer" name="CustomerForm" type="com.cargo.gen.CustomerForm" > ... ... ... <html:hidden property="methodToExecute" value="error"/> <SCRIPT>function set(target) {document.forms[0].methodToExecute.value=target;}</SCRIPT> <html:submit on click="set('regCustomer')">RegisterCustomer</html:submit> <html:submit on click="set('updateCustomer');">SaveChanges</html:submit> <html:submit property="methodToExecute">Update</html:submit> <html:submit property="methodToExecute">Delete</html:submit> </html:form> </body> </html>
|
 |
Chris Mathews
Ranch Hand
Joined: Jul 18, 2001
Posts: 2712
|
|
|
You should include the struts-legacy.jar in your war's lib directory. This jar can be found in the standard Struts 1.1 distribution.
|
 |
Tokunbo Oke
Ranch Hand
Joined: Sep 09, 2003
Posts: 57
|
|
|
Thanks for your response I added legacy as you recommended and it solved my problem.
|
 |
 |
|
|
subject: DispatchAction error .... NoClassDefFoundError...
|
|
|