javax.validation.ConstraintViolationException: validation failed for classes [*] during update time for groups [javax.validation.groups.Default, ]

This message wasted many hours to figure out the solution.

javax.validation.ConstraintViolationException: validation failed for classes [*] during update time for groups [javax.validation.groups.Default, ]

When I applied the validation as following, I found that the confirmPassword is the field causing validation error.

ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
        Validator validator = factory.getValidator();
       
        Set<ConstraintViolation<User>> constraintViolations = validator.validate(user);

        System.out.println("constraintViolations.size : "+constraintViolations.size());
        Iterator<ConstraintViolation<User>> iterator = constraintViolations.iterator();
        while (iterator.hasNext()) {
            ConstraintViolation<dpgsource.users.User> constraintViolation = (ConstraintViolation<dpgsource.users.User>) iterator
                    .next();
            System.out.println(constraintViolation.getMessage()+", "+constraintViolation.getInvalidValue()+", "+constraintViolation.getPropertyPath());
        }


Searching perticular extension file in All or Specified location of system using java program

import java.io.*;

public class SearchFile {

    public static void main(String... ar) throws Exception {
        File f1 = new File("F:/");
        printFiles(f1);
    }

    static void printFiles(File f) {
        File files[] = f.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File n = files[i];
                if (!= null & (n.isDirectory() || n.isFile())) {
                    String s = n.getName();
                    // check for pdf file
                    if (s.endsWith(".pdf")) {
                        System.out.println("  " + n.getAbsolutePath());
                    }
                    if (n.isDirectory()) {
                        printFiles(n);
                    }
                }
            }
        }
    }
}

Popular Posts