bval-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "viktor (JIRA)" <>
Subject [jira] [Created] (BVAL-125) "No validator could be found for type ..." for overloaded methods with more specific return type
Date Fri, 21 Mar 2014 13:57:43 GMT
viktor created BVAL-125:

             Summary: "No validator could be found for type ..." for overloaded methods with
more specific return type
                 Key: BVAL-125
             Project: BVal
          Issue Type: Bug
    Affects Versions: 0.5
         Environment: Java(TM) SE Runtime Environment (build 1.8.0-b132)
Linux 3.11.10-7-desktop x86_64
            Reporter: viktor


import java.lang.reflect.Method;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.ValidatorFactory;

public class App {
  public static interface Identifiable {
    Object getId();
  public static class Test implements Identifiable {
    @javax.validation.constraints.Pattern(regexp = "\\w+")
    public String getId() {
      return "ok";
  public static void main(String[] args) {
    ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
    Test test = new Test();
    System.out.println("methods: ");
    for(Method m: test.getClass().getMethods()) {
      System.out.println("  " + m);
    Set<ConstraintViolation<Test>> set = vf.getValidator().validate(test);
    System.out.println("set:" + set);

Print to ouput stream: 

  public java.lang.String ru.kih.test.App$Test.getId()
  public java.lang.Object ru.kih.test.App$Test.getId()
  ... other methods was skipped ...
Exception in thread "main" javax.validation.UnexpectedTypeException: No validator could be
found for type java.lang.Object. See: @Pattern at public java.lang.Object ru.kih.test.App$Test.getId()
	at org.apache.bval.jsr303.AnnotationProcessor.checkOneType(
	at org.apache.bval.jsr303.AnnotationProcessor.getConstraintValidator(
	at org.apache.bval.jsr303.AnnotationProcessor.applyConstraint(
	at org.apache.bval.jsr303.AnnotationProcessor.processAnnotation(
	at org.apache.bval.jsr303.AnnotationProcessor.processAnnotations(
	at org.apache.bval.jsr303.Jsr303MetaBeanFactory.processClass(
	at org.apache.bval.jsr303.Jsr303MetaBeanFactory.buildMetaBean(
	at org.apache.bval.MetaBeanBuilder.buildForClass(
	at org.apache.bval.MetaBeanManager.findForClass(
	at org.apache.bval.jsr303.ClassValidator.validate(
	at ru.kih.test.App.main(

This message was sent by Atlassian JIRA

View raw message