javax.validation.ConstraintDeclarationException: HV000141: The constraint com.test.validation.constraints.CustomMin used ConstraintTarget#IMPLICIT where the target cannot be inferred.

Hibernate JIRA | George Fountopoulos | 3 years ago
  1. 0

    I have created a {{CustomMin}} constraint, which is an exact copy of {{javax.validation.constraints.Min as follows}}: {code:title=CustomMin.java} @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = { }) public @interface CustomMin { String message() default "{javax.validation.constraints.Min.message}"; Class<?>[] groups() default { }; Class<? extends Payload>[] payload() default { }; /** * @return value the element must be higher or equal to */ long value(); /** * Defines several {@link CustomMin} annotations on the same element. * * @see CustomMin */ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @interface List { CustomMin[] value(); } } {code} I am trying to validate parameters using the {{ExecutableValidator}} as follows: {code:title=TestValidator.java} package com.test.validation.constraints; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.ValidatorFactory; import javax.validation.constraints.Min; import javax.validation.executable.ExecutableValidator; import java.lang.reflect.Method; import java.util.Set; public class TestValidator { @CustomMin(1) public Integer test(@Min(1) Integer i) { return i; } public static void main(String[] args) throws Exception { TestValidator customerFacade = new TestValidator(); Method method = TestValidator.class.getMethod("test", Integer.class); Object[] parameterValues = {0}; ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); ExecutableValidator executableValidator = factory.getValidator().forExecutables(); Set<ConstraintViolation<TestValidator>> parameterViolations = executableValidator.validateParameters( customerFacade, method, parameterValues ); System.out.println("parameterViolations = " + parameterViolations); } } {code} The above is causing the following exception: {code} Exception in thread "main" javax.validation.ConstraintDeclarationException: HV000141: The constraint com.test.validation.constraints.CustomMin used ConstraintTarget#IMPLICIT where the target cannot be inferred. at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.determineConstraintType(ConstraintDescriptorImpl.java:404) at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:186) at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:208) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.buildConstraintDescriptor(AnnotationMetaDataProvider.java:588) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraintAnnotations(AnnotationMetaDataProvider.java:515) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraints(AnnotationMetaDataProvider.java:469) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findExecutableMetaData(AnnotationMetaDataProvider.java:313) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMetaData(AnnotationMetaDataProvider.java:294) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMethodMetaData(AnnotationMetaDataProvider.java:280) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.retrieveBeanConfiguration(AnnotationMetaDataProvider.java:143) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfiguration(AnnotationMetaDataProvider.java:130) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfigurationForHierarchy(AnnotationMetaDataProvider.java:113) at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:187) at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(BeanMetaDataManager.java:152) at org.hibernate.validator.internal.engine.ValidatorImpl.validateParametersInContext(ValidatorImpl.java:878) at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:240) at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:198) at com.test.validation.constraints.TestValidator.main(TestValidator.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) {code}

    Hibernate JIRA | 3 years ago | George Fountopoulos
    javax.validation.ConstraintDeclarationException: HV000141: The constraint com.test.validation.constraints.CustomMin used ConstraintTarget#IMPLICIT where the target cannot be inferred.
  2. 0

    I have created a {{CustomMin}} constraint, which is an exact copy of {{javax.validation.constraints.Min as follows}}: {code:title=CustomMin.java} @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = { }) public @interface CustomMin { String message() default "{javax.validation.constraints.Min.message}"; Class<?>[] groups() default { }; Class<? extends Payload>[] payload() default { }; /** * @return value the element must be higher or equal to */ long value(); /** * Defines several {@link CustomMin} annotations on the same element. * * @see CustomMin */ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @interface List { CustomMin[] value(); } } {code} I am trying to validate parameters using the {{ExecutableValidator}} as follows: {code:title=TestValidator.java} package com.test.validation.constraints; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.ValidatorFactory; import javax.validation.constraints.Min; import javax.validation.executable.ExecutableValidator; import java.lang.reflect.Method; import java.util.Set; public class TestValidator { @CustomMin(1) public Integer test(@Min(1) Integer i) { return i; } public static void main(String[] args) throws Exception { TestValidator customerFacade = new TestValidator(); Method method = TestValidator.class.getMethod("test", Integer.class); Object[] parameterValues = {0}; ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); ExecutableValidator executableValidator = factory.getValidator().forExecutables(); Set<ConstraintViolation<TestValidator>> parameterViolations = executableValidator.validateParameters( customerFacade, method, parameterValues ); System.out.println("parameterViolations = " + parameterViolations); } } {code} The above is causing the following exception: {code} Exception in thread "main" javax.validation.ConstraintDeclarationException: HV000141: The constraint com.test.validation.constraints.CustomMin used ConstraintTarget#IMPLICIT where the target cannot be inferred. at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.determineConstraintType(ConstraintDescriptorImpl.java:404) at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:186) at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:208) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.buildConstraintDescriptor(AnnotationMetaDataProvider.java:588) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraintAnnotations(AnnotationMetaDataProvider.java:515) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraints(AnnotationMetaDataProvider.java:469) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findExecutableMetaData(AnnotationMetaDataProvider.java:313) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMetaData(AnnotationMetaDataProvider.java:294) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMethodMetaData(AnnotationMetaDataProvider.java:280) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.retrieveBeanConfiguration(AnnotationMetaDataProvider.java:143) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfiguration(AnnotationMetaDataProvider.java:130) at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfigurationForHierarchy(AnnotationMetaDataProvider.java:113) at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:187) at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(BeanMetaDataManager.java:152) at org.hibernate.validator.internal.engine.ValidatorImpl.validateParametersInContext(ValidatorImpl.java:878) at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:240) at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:198) at com.test.validation.constraints.TestValidator.main(TestValidator.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) {code}

    Hibernate JIRA | 3 years ago | George Fountopoulos
    javax.validation.ConstraintDeclarationException: HV000141: The constraint com.test.validation.constraints.CustomMin used ConstraintTarget#IMPLICIT where the target cannot be inferred.
  3. 0

    conflict at com.jcabi.s3.AwsBucket.ocket

    GitHub | 8 months ago | yegor256
    java.lang.IllegalStateException: [POST http://www.netbout.com/b/35087/upload?ctype=text%2Fx-markdown&etag=003164cfc22d7c5a089b4008ad8538aa&name=ledger] failed in 5ms: HV000151: A method overriding another method must not alter the parameter constraint configuration, but method public com.jcabi.s3.Ocket com.jcabi.s3.AwsBucket.ocket(java.lang.String) changes the configuration of public abstract com.jcabi.s3.Ocket com.jcabi.s3.Bucket.ocket(java.lang.String).
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JSF Bean-Validation throws javax.validation.ConstraintDeclarationException: HV000141

    Stack Overflow | 2 years ago
    javax.validation.ConstraintDeclarationException: HV000141: The constraint com.jpa.validator.CustomNotEmptyStringValidator used ConstraintTarget#IMPLICIT where the target cannot be inferred.
  6. 0

    For a purely composed cross-parameter constraint (i.e. a constraint which has no own validator but is annotated with another cross-parameter constraint), the validation target needs to be retrieved from the composing constraint(s). Currently such a constraint causes the following exception: {code} javax.validation.ConstraintDeclarationException: HV000132: Void methods must not be constrained or marked for cascaded validation, but method public void org.hibernate.validator.test.internal.constraintvalidators.ScriptAssertValidatorTest$CalendarService.createCalendarEvent(java.lang.String,java.util.Date,java.util.Date) is. at org.hibernate.validator.internal.metadata.aggregated.ExecutableMetaData$Builder.checkReturnValueConfiguration(ExecutableMetaData.java:479) at org.hibernate.validator.internal.metadata.aggregated.ExecutableMetaData$Builder.build(ExecutableMetaData.java:362) at org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl$BuilderDelegate.build(BeanMetaDataImpl.java:601) at org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl$BeanMetaDataBuilder.build(BeanMetaDataImpl.java:508) at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:182) {code}

    Hibernate JIRA | 4 years ago | Gunnar Morling
    javax.validation.ConstraintDeclarationException: HV000132: Void methods must not be constrained or marked for cascaded validation, but method public void org.hibernate.validator.test.internal.constraintvalidators.ScriptAssertValidatorTest$CalendarService.createCalendarEvent(java.lang.String,java.util.Date,java.util.Date) is.

    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.ConstraintDeclarationException

      HV000141: The constraint com.test.validation.constraints.CustomMin used ConstraintTarget#IMPLICIT where the target cannot be inferred.

      at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.determineConstraintType()
    2. Hibernate Validator Engine
      ValidatorImpl.validateParameters
      1. org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.determineConstraintType(ConstraintDescriptorImpl.java:404)
      2. org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:186)
      3. org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:208)
      4. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.buildConstraintDescriptor(AnnotationMetaDataProvider.java:588)
      5. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraintAnnotations(AnnotationMetaDataProvider.java:515)
      6. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraints(AnnotationMetaDataProvider.java:469)
      7. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findExecutableMetaData(AnnotationMetaDataProvider.java:313)
      8. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMetaData(AnnotationMetaDataProvider.java:294)
      9. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMethodMetaData(AnnotationMetaDataProvider.java:280)
      10. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.retrieveBeanConfiguration(AnnotationMetaDataProvider.java:143)
      11. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfiguration(AnnotationMetaDataProvider.java:130)
      12. org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfigurationForHierarchy(AnnotationMetaDataProvider.java:113)
      13. org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:187)
      14. org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(BeanMetaDataManager.java:152)
      15. org.hibernate.validator.internal.engine.ValidatorImpl.validateParametersInContext(ValidatorImpl.java:878)
      16. org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:240)
      17. org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:198)
      17 frames
    3. com.test.validation
      TestValidator.main
      1. com.test.validation.constraints.TestValidator.main(TestValidator.java:23)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    5. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      1 frame