Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:14:09+00:00 2026-06-04T18:14:09+00:00

I use Spring and Spring MVC 3.1, Hibernate 3, Hibernate Validator 4.3. I want

  • 0

I use Spring and Spring MVC 3.1, Hibernate 3, Hibernate Validator 4.3.

I want to add my custom constraint validator, but it seems that my validator not called and always got “No validator could be found for type” exception. Did I make any mistake?
I got a big problem of getting this exception always

javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.lang.String.
    at org.hibernate.validator.internal.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:394)
    at org.hibernate.validator.internal.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:375)

But if I remove my custom constraint validator, everything works fine.
Here is my code, could you help find the source to cause this exception?

test.constraint.ActorConstraint

@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy=ActorConstraintValidator.class)
public @interface ActorConstraint {

  String message() default "Actor already exists in database";
  public abstract Class<?>[] groups() default {};
  public abstract Class<? extends Payload>[] payload() default {};

}



test.constraint.ActorConstraintValidator
@Component
public class ActorConstraintValidator implements ConstraintValidator<ActorConstraint, Actor> {

  @Autowired
  private ActorModel actorModel;

  @Override
  public void initialize(ActorConstraint arg0) {
    System.out.println("ActorConstraintValidator is initialized");
  }

  @Override
  public boolean isValid(Actor actor, ConstraintValidatorContext context) {

    boolean pass = true;

    if (getActorModel().isActorExist(actor.getName()) ){
      pass = false;
    }
    return pass;
  }


  public ActorModel getActorModel() {
    return actorModel;
  }

  public void setActorModel(ActorModel actorModel) {
    this.actorModel = actorModel;
  }  
}



test.entity.Actor

@Entity  /*(findByName named query definition is omitted)*/
public class Actor implements Serializable {

  public static final String NAMED_QUERY__FIND_ACTOR_BY_NAME = "findActorByName";

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @ActorConstraint
  @NotEmpty
  private String name;

  @DateTimeFormat(iso=ISO.DATE)
  private Date birthday;

  @Min(0)
  @Max(300)
  private Integer height;

  ...
 }

extra note, I have added

<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>

to spring xml

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:14:11+00:00Added an answer on June 4, 2026 at 6:14 pm

    You put the @ActorConstraint to the field name which is of type String, while the validator type ActorConstraintValidator is parametrized with Actor. That is, there is no validator for the @ActorConstraint constraint and type String.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hibernate's validator is my JSR-303 provider in my Spring MVC application. When I use
I'm trying to use hibernate with spring 3 mvc but at the moment I
We all know, that Spring MVC integrate well with Hibernate Validator and JSR-303 in
I am using Spring MVC and Hibernate. I want to use the OpenSessionInViewFilter to
I have Spring MVC web-application. I want to use Hibernate and AJAX. There are
I have correctly setup Hibernate Validator in Spring MVC application. Beans are validated, but
In Spring MVC Hibernate application , when i am trying to use properties file
I work on Spring MVC + Hibernate application, use MySQL (ver. 5.0.51a) with the
I use Spring MVC [version: 2.5] and Security[version: 2.0.4]. My problem looks like that:
I have learned how to use Spring MVC 3, but I am very interested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.