I am trying to learn JSF doing a demo project. When I try to add validator to some components, I get java.lang.ClassNotFoundException: com.test.validator.TestValidator
My faces-config looks like this
<validator>
<validator-id>Validator</validator-id>
<validator-class>com.test.validator.TestValidator</validator-class>
</validator>
Validator class
public class TestValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent componentToValidate,
Object value) throws ValidatorException {
//Add code
}
}
and finally facelet
<f:validator validatorId="Validator"></f:validator>
I am not sure if I am missing something. All help are appreciated. Thanks
I can think of a number of possible causes:
The TestValidator class is missing a package
declaration, so you've actually declared it in the default package... as noted by @Jigar Joshi.
You haven't compiled it.
You haven't created / updated the JAR that contains the class.
You haven't included the JAR in the WAR / EAR.
The WAR / EAR (or the webserver) is missing the JAR file that contains some class that your TestValidator depends on. (Seems unlikely...)
You haven't redeployed the WAR / EAR.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.