javax.validation.UnexpectedTypeException: No validator could be found for type: javax.swing.JTextField

Hibernate JIRA | Jay Gorrell | 4 years ago
  1. 0

    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. {noformat}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){noformat} This is the test class: {noformat} 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(); } {noformat}

    Hibernate JIRA | 4 years ago | Jay Gorrell
    javax.validation.UnexpectedTypeException: No validator could be found for type: javax.swing.JTextField
  2. 0

    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. {noformat}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){noformat} This is the test class: {noformat} 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(); } {noformat}

    Hibernate JIRA | 4 years ago | Jay Gorrell
    javax.validation.UnexpectedTypeException: No validator could be found for type: javax.swing.JTextField
  3. 0

    Hibernate Validator throwing Exception "No validator could be found for type: java.math.BigDecimal"

    Stack Overflow | 3 years ago | Rahul Agrawal
    javax.validation.UnexpectedTypeException: No validator could be found for type: java.math.BigDecimal
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JSR 303 - Hibernate Validation 4.2.0 - UnexpectedTypeException - @Valid and @Size in combination

    Stack Overflow | 5 years ago | Walter
    javax.validation.UnexpectedTypeException: No validator could be found for type: B
  6. 0

    Using hibernate validator JodaTime bean validation constraints in JBoss

    Stack Overflow | 4 years ago | woelfle
    javax.validation.UnexpectedTypeException: No validator could be found for type: org.joda.time.DateTime

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. javax.validation.UnexpectedTypeException

      No validator could be found for type: javax.swing.JTextField

      at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique()
    2. Vaadin
      ConstraintTree.validateConstraints
      1. org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:383)
      2. org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:364)
      3. org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:313)
      4. org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:144)
      5. org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:117)
      5 frames
    3. Embedded GlassFish Web
      MetaConstraint.validateConstraint
      1. org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:84)
      1 frame
    4. Vaadin
      ValidatorImpl.validateValue
      1. org.hibernate.validator.engine.ValidatorImpl.validatePropertyForDefaultGroup(ValidatorImpl.java:829)
      2. org.hibernate.validator.engine.ValidatorImpl.validatePropertyForCurrentGroup(ValidatorImpl.java:742)
      3. org.hibernate.validator.engine.ValidatorImpl.validateValueInContext(ValidatorImpl.java:699)
      4. org.hibernate.validator.engine.ValidatorImpl.validateValue(ValidatorImpl.java:176)
      4 frames