Issue Type: Bug Bug
Affects Versions: 4.2.0.Final
Assignee: Unassigned
Components: validators
Created: 16/Aug/12 2:02 PM
Description:

I'm trying to validate individual UI text fields so that I can display user cues as the user is typing. When I call validateValue() on the string returned by the field I get the exception below. The test is below the exception. In the test I pass a string to validateValue() but it complains that there isn't a constraint validator for the JTextField where the validation annotation is attached. Since the text field isn't being referenced (it isn't even instantiated in the test case) it shouldn't matter where the validation was defined.

Exception from validateValue() call.

Exception in thread "main" javax.validation.UnexpectedTypeException: No validator could be found for type: javax.swing.JTextField
	at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:383)
	at org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:364)
	at org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:313)
	at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:144)
	at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:117)
	at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:84)
	at org.hibernate.validator.engine.ValidatorImpl.validatePropertyForDefaultGroup(ValidatorImpl.java:829)
	at org.hibernate.validator.engine.ValidatorImpl.validatePropertyForCurrentGroup(ValidatorImpl.java:742)
	at org.hibernate.validator.engine.ValidatorImpl.validateValueInContext(ValidatorImpl.java:699)
	at org.hibernate.validator.engine.ValidatorImpl.validateValue(ValidatorImpl.java:176)
	at com.tpt.common.Test.main(Test.java:21)

This is the test class:

import javax.swing.JTextField;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

import org.hibernate.validator.constraints.NotBlank;

public class Test {
  
  public static void main(String[] args) {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();
    
    // Throws exception
    validator.validateValue(TestPanel.class, "testField", "testString", new Class[0]); 
  }
}

class TestPanel {
  @NotBlank
  public JTextField testField = new JTextField();
}
Environment: My test was run on Java 1.6.0_27 in Eclipse.
Project: Hibernate Validator
Labels: validation
Priority: Major Major
Reporter: Jay Gorrell
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira