This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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 Make it so: Java DB Connections & Transactions this week in the JDBC 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.
I agree. Here's the link:
subject: DispatchAction error .... NoClassDefFoundError...
It's not a secret anymore!