File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes DispatchAction error .... NoClassDefFoundError... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DispatchAction error .... NoClassDefFoundError..." Watch "DispatchAction error .... NoClassDefFoundError..." New topic

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

root cause
java.lang.NoClassDefFoundError: org/apache/struts/legacy/GenericDataSource
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(


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 {
return mapping.findForward("success");


<action path="/customer"
<forward name="success" path="/jsp/success.jsp"/>
<forward name="failure" path="/jsp/failure.jsp"/>

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<title><bean:message key="fieldL.title" /></title>

<table width="500"
border="0" cellspacing="0" cellpadding="0">
<td> </td>
<td height="68" width="48%">
<div align="left">
<img src="file:///D|/Apps/Apache/Tomcat-4.1.27/webapps/employees/images/wxmainlogowhitespace.gif">
<td> </td>
<html:form action="/customer"
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>


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.
wood burning stoves
subject: DispatchAction error .... NoClassDefFoundError...
It's not a secret anymore!