You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by struts <st...@hakodatecgi.com> on 2003/08/15 08:33:50 UTC
ValidatorForm NoClassDefError every other Tomcat reload
Hi-
After extending a form bean from an ActionForm class to a
ValidatorForm Class I get a java.lang.NoClassDefFoundError on every other Tomcat Reload.
On even reloads I get the NoClass error.
On odd reloads everything works fine.
The error message points to this line in my addUserAction class.
User user = new User();
User is the form bean that extends ValidatorForm. When I switch back to extends ActionForm there are no problems.
I get the problem when working in NetBeans 3.5 with a 4.06 Internal Tomcat on WinXP.
I don't have any problems when I run the same code from a Linux Tomcat 5 server.
I added my test code to the struts-blank war from the jakarta-struts-1.1-b3 distro
I'm new to Struts so my question is:
Is it my poor coding that is bringing about the bug?
Or is it a Struts doesn't work on Tomcat Version xxxx problem. Or a possible NetBeans/ Struts bug.
I've listed my code and settings below.
Cheers,
David Sperling
/******* Error
root cause
java.lang.NoClassDefFoundError: org.apache.struts.validator.ValidatorForm
at com.hakodatecgi.bbs.action.AddUserAction.execute(AddUserAction.java:37)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:226)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
/***** validation.xml
<form-validation>
<global>
</global>
<formset>
<form name="inputUserForm">
<field
property="userName"
depends="required">
<arg0 key="title" resource="false"/>
</field>
</form>
</formset>
</form-validation>
/***** struts-config
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean
name="inputUserForm"
type="com.hakodatecgi.bbs.om.User"/>
</form-beans>
<action-mappings>
<action
path="/AddUser"
type="com.hakodatecgi.bbs.action.AddUserAction"
name="inputUserForm"
scope="session"
validate="false">
<forward name="success" path="/inputUserForm.jsp"/>
</action>
<action
path="/UserAUD"
type="com.hakodatecgi.bbs.action.UserAUDAction"
name="inputUserForm"
input="/inputUserForm.jsp"
scope="session"
validate="true"
parameter="action">
<forward name="added" path="/index.jsp"/>
</action>
</action-mappings>
<message-resources parameter="resources.application"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
/****** User.java
package com.hakodatecgi.bbs.om;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorForm;
/**
*/
public class User extends ValidatorForm {
private String userName;
public java.lang.String getUserName() {
return userName;
}
public void setUserName(java.lang.String userName) {
this.userName = userName;
}
}
/***** AddUserAction
package com.hakodatecgi.bbs.action;
import com.hakodatecgi.bbs.om.User;
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.ActionForward;
import org.apache.struts.action.ActionMapping;
public class AddUserAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
request.getSession().setAttribute("mode", "add");
// Create a new user for the form
User user = new User();
request.getSession(true).setAttribute(mapping.getName(), user);
return mapping.findForward("success");
}
}
/***** inputUserForm.jsp
<%@page import="com.hakodatecgi.bbs.om.*" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<h1>This is the edit customer Page This is the mode is:</h1> <html:errors/> <html:form action="/UserAUD.do"enctype="multipart/form-data">
userName
<html:text size="50" property="userName" />
<html:submit property="action">
<bean:message key="user.add.button.label"/>
</html:submit>
</html:form>
/***** UserAUDAction.java
package com.hakodatecgi.bbs.action;
import com.hakodatecgi.bbs.om.User;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.LookupDispatchAction;
public class UserAUDAction extends LookupDispatchAction {
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("user.add.button.label", "add");
return map;
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (isCancelled(request)) {
return mapping.findForward("cancel");
} else {
return super.execute(mapping, form, request, response);
}
}
public ActionForward add(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
//BBSBO bbsbo = BBSBO.getInstance( getDataSource(request));
//bbsbo.create((User)form);
return mapping.findForward("added");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: ValidatorForm NoClassDefError every other Tomcat reload
Posted by struts <st...@hakodatecgi.com>.
Hi-
I fixed the problem by changing:
User user = new User(); to
User user = (User)form;
If anyone could tell me what why "User user = new User();" doesn't work or is incorrect
and "User user = (User)form;" does work I'd greatly appreciate it.
BTW "User user = new User(); " worked fine when I tested it on Tomcat 5 Linux and Tomcat 4.1XP.
Cheers,
David Sperling
-----Original Message-----
From: struts [mailto:struts@hakodatecgi.com]
Sent: Friday, August 15, 2003 3:34 PM
To: struts-user@jakarta.apache.org
Subject: ValidatorForm NoClassDefError every other Tomcat reload
Hi-
After extending a form bean from an ActionForm class to a
ValidatorForm Class I get a java.lang.NoClassDefFoundError on every other Tomcat Reload.
On even reloads I get the NoClass error.
On odd reloads everything works fine.
The error message points to this line in my addUserAction class.
User user = new User();
User is the form bean that extends ValidatorForm. When I switch back to extends ActionForm there are no problems.
I get the problem when working in NetBeans 3.5 with a 4.06 Internal Tomcat on WinXP.
I don't have any problems when I run the same code from a Linux Tomcat 5 server.
I added my test code to the struts-blank war from the jakarta-struts-1.1-b3 distro
I'm new to Struts so my question is:
Is it my poor coding that is bringing about the bug?
Or is it a Struts doesn't work on Tomcat Version xxxx problem. Or a possible NetBeans/ Struts bug.
I've listed my code and settings below.
Cheers,
David Sperling
/******* Error
root cause
java.lang.NoClassDefFoundError: org.apache.struts.validator.ValidatorForm
at com.hakodatecgi.bbs.action.AddUserAction.execute(AddUserAction.java:37)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:226)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
/***** validation.xml
<form-validation>
<global>
</global>
<formset>
<form name="inputUserForm">
<field
property="userName"
depends="required">
<arg0 key="title" resource="false"/>
</field>
</form>
</formset>
</form-validation>
/***** struts-config
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean
name="inputUserForm"
type="com.hakodatecgi.bbs.om.User"/>
</form-beans>
<action-mappings>
<action
path="/AddUser"
type="com.hakodatecgi.bbs.action.AddUserAction"
name="inputUserForm"
scope="session"
validate="false">
<forward name="success" path="/inputUserForm.jsp"/>
</action>
<action
path="/UserAUD"
type="com.hakodatecgi.bbs.action.UserAUDAction"
name="inputUserForm"
input="/inputUserForm.jsp"
scope="session"
validate="true"
parameter="action">
<forward name="added" path="/index.jsp"/>
</action>
</action-mappings>
<message-resources parameter="resources.application"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
/****** User.java
package com.hakodatecgi.bbs.om;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorForm;
/**
*/
public class User extends ValidatorForm {
private String userName;
public java.lang.String getUserName() {
return userName;
}
public void setUserName(java.lang.String userName) {
this.userName = userName;
}
}
/***** AddUserAction
package com.hakodatecgi.bbs.action;
import com.hakodatecgi.bbs.om.User;
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.ActionForward;
import org.apache.struts.action.ActionMapping;
public class AddUserAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
request.getSession().setAttribute("mode", "add");
// Create a new user for the form
User user = new User();
request.getSession(true).setAttribute(mapping.getName(), user);
return mapping.findForward("success");
}
}
/***** inputUserForm.jsp
<%@page import="com.hakodatecgi.bbs.om.*" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<h1>This is the edit customer Page This is the mode is:</h1> <html:errors/> <html:form action="/UserAUD.do"enctype="multipart/form-data">
userName
<html:text size="50" property="userName" />
<html:submit property="action">
<bean:message key="user.add.button.label"/>
</html:submit>
</html:form>
/***** UserAUDAction.java
package com.hakodatecgi.bbs.action;
import com.hakodatecgi.bbs.om.User;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.LookupDispatchAction;
public class UserAUDAction extends LookupDispatchAction {
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("user.add.button.label", "add");
return map;
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (isCancelled(request)) {
return mapping.findForward("cancel");
} else {
return super.execute(mapping, form, request, response);
}
}
public ActionForward add(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
//BBSBO bbsbo = BBSBO.getInstance( getDataSource(request));
//bbsbo.create((User)form);
return mapping.findForward("added");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org