I added the commons validator to my Struts implementation. The
out-of-the-box stuff is working just fine. However, I added the following
custom validator:

public class BarnmanValidator implements Serializable {
    public static boolean validateEmailAddress(Object bean, Field field) {

[etc, etc, etc]

When this one is about to be invoked, I get this exception (as root cause of
a servlet exception):

java.lang.NoClassDefFoundError: org/apache/commons/validator/Field
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:1647)
        at java.lang.Class.getMethod0(Class.java:1893)
        at java.lang.Class.getMethod(Class.java:976)
        at
org.apache.commons.validator.Validator.validateFieldForRule(Validator.java:4
01)

the validator def:

<validator name="email.unique"
             classname="com.springwell.barnman.validator.BarnmanValidator"
             method="validateEmailAddress"

methodParams="java.lang.Object,org.apache.commons.validator.Field"
             msg="errors.email.duplicate"
/>

the form def:

<form name="register" >
        <field property="emailAddress" depends="required,email,email.unique" />
        <field property="password1" depends="required" />
        <field property="password2" depends="required" />
        <field property="firstName" depends="required" />
        <field property="lastName" depends="required" />
</form>

If I omit my custom validator everything works fine.

the commons-validator.jar is in my war file's WEB-INF/lib, and there seems
to be no problem locating org.apache.commons.validator.Validator (as you can
tell from the stacktrace). Only thing I can think of is that it's a
different classloader trying to load the Field class through reflection? Any
known solutions to known problems?


thanks in advance,
Rob


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to