Ok I figured out a way to make it all work ...
The solution ended up being to put all the commons jar files in the root of
the ear, and add them to application.xml as java modules. Looks like it was
indeed a classloader issue then ... which would lead me to think that this
is a bug. No reason why Struts shouldn't be able to do all of the
reflection, especially since this is hardly pushing the envelope. Any
thoughts?
cheers
Rob
-Original Message-
From: Rob van Oostrum [mailto:[EMAIL PROTECTED]
Sent: November 14, 2003 6:11 PM
To: [EMAIL PROTECTED]
Subject: NoClassDefFoundError in custom validator
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(Valida
tor.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]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]