File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts 1.2.7 Validation blues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.2.7 Validation blues" Watch "Struts 1.2.7 Validation blues" New topic

Struts 1.2.7 Validation blues

Jan van Doorn

Joined: Feb 12, 2003
Posts: 21

I have wasted many hours on trying to solve this one:

- working with struts 1.2.7, Resin 3.0.14, jdk1.4.

Want to implement Struts validation using validation.xml.

I have a simple Loginform with 2 fields (, registered in struts-config.xml:

<form-bean name="LoginForm" type="nl.upi.workmate.struts.umba.LoginForm" >
<form-property name="userId" type="java.lang.String" />
<form-property name="passWord" type="java.lang.String" />

� and corresponding action:

<forward name="valid" path="/jsp/MainMenu.jsp" />
<forward name="invalid" path="/jsp/LoginView.jsp" />

I defined the plugin in struts-config.xml:

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"

Then why does it not work ??!!
BTW: it does work under Struts 1.1.

When I press submit in the Loginform I get this in the Resin-console:

[22:05:26.256] Server[] starting
[22:05:26.286] http listening to *:80
[22:05:26.316] hmux listening to localhost:6802
[22:05:26.356] Host[] starting
[22:05:26.447] WebApp[http://localhost:80] starting
[22:05:27.027] In-place class redefinition (HotSwap) is not available. In-place class reloading during development requ
ires a compatible JDK and -Xdebug.
[22:05:27.057] WebApp[http://localhost:80/workmate] starting
[22:05:27.758] action: init
** LoginForm.setUserId() <-- ActionForm gets called
** LoginForm.setPassWord()
[22:05:35,129] ERROR ValidatorForm:112 - org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.
apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, jav
org.apache.commons.validator.ValidatorException: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Obje
ct, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErr
ors, javax.servlet.http.HttpServletRequest)

at org.apache.commons.validator.ValidatorAction.loadValidationMethod(
at org.apache.commons.validator.ValidatorAction.executeValidationMethod(
at org.apache.commons.validator.Field.validateForRule(
at org.apache.commons.validator.Field.validate(
at org.apache.commons.validator.Form.validate(
at org.apache.commons.validator.Validator.validate(
at org.apache.struts.validator.ValidatorForm.validate(
at org.apache.struts.action.RequestProcessor.processValidate(
at org.apache.struts.action.RequestProcessor.process(
at org.apache.struts.action.ActionServlet.process(
at org.apache.struts.action.ActionServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at com.caucho.server.dispatch.ServletFilterChain.doFilter(
at com.caucho.server.webapp.WebAppFilterChain.doFilter(
at com.caucho.server.dispatch.ServletInvocation.service(
at com.caucho.server.http.HttpRequest.handleRequest(
at com.caucho.util.ThreadPool.runTasks(
LoginAction.execute() <-- Action object should not be called since validation failed
LoginAction.execute() - einde
LoginAction.execute() - invalid
** LoginForm.getUserId()
** LoginForm.getPassWord()

Please help me out on this one !!

Thanks in advance.

[ July 25, 2005: Message edited by: Jan van Doorn ]
[ July 25, 2005: Message edited by: Jan van Doorn ]
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
ActionErrors/ActionError are deprecated since 1.2.x. it looks like you may have validator-rules.xml file (old) that is still defining validator rules using these classes. change these to ActionMessages/ActionMessage instead.

-/a<br />certified slacker...yes, my last name is 'do' - <a href="" target="_blank" rel="nofollow"></a>
Jan van Doorn

Joined: Feb 12, 2003
Posts: 21
Problem solved !

Reason: there were no corresponding error messages in the Resource file.

<validator name="required"

Looking at an entry in validator-rules.xml:

methodParams="java.lang.Object,org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages,org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest"

... I now understand the exception.

The error was caused because I had no entry for errors.required

[ July 26, 2005: Message edited by: Jan van Doorn ]
I agree. Here's the link:
subject: Struts 1.2.7 Validation blues
jQuery in Action, 3rd edition