Friday, September 13, 2013

JSF Errors: JSF1005: Cannot instantiate validator of type ...

JSF1005 error is one of less common. The error can be thrown when JSF Application object tries to create new Validator. To create a Validator, the framework uses the method createValidator. Exception could be thrown when specified Validator can not be found, primarily when Validator Map (contained by Application object) doesn't contain it:

public Validator createValidator(String validatorId)
    throws FacesException
  {
    Util.notNull("validatorId", validatorId);
     Validator returnVal = (Validator)newThing(validatorId, this.validatorMap);
     if (returnVal == null) {
       Object[] params = { validatorId };
       if (LOGGER.isLoggable(Level.SEVERE)) {
         LOGGER.log(Level.SEVERE, "jsf.cannot_instantiate_validator_error", params);
       } 
       // !!! The error will be thrown here.

       etc..

In the Mojarra implementation, if the Validator cannot be find, additional exception message can be logged: Expression Error: Named Object: 'your_validator_name' not found
When Validator object cannot be created for other reasons then will be thrown:
  • AssertionError
  • FacesException with message "Cannot instantiate class"
  • Under certain conditions another FacesMessage form methods com.sun.faces.Application.newThing or com.sun.faces.util.Util.loadClass

No comments:

Post a Comment