[
http://opensource.atlassian.com/projects/hibernate/browse/HV-469?page=com...
]
Gunnar Morling commented on HV-469:
-----------------------------------
David, there is a problem with your custom constraint {{@CompositeTest}}. This constraint
references the validator type {{SizeValidatorForString}} within the {{@Constraint}}
meta-annotation. This validator is a validator for the {{@Size}} annotation, you would
have to reference a validator parametrized with the {{@CompositeTest}} annotation type
instead. In case you want to create a constraint which is just composed from some other
existing constraints but doesn't add any own validation logic, just use an empty array
for the "validatedBy" attribute of the {{@Constraint}} meta-annotation.
ClassCast exception when creating Combined constraint
-----------------------------------------------------
Key: HV-469
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-469
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 4.2.0.Beta2
Reporter: David J. M. Karlsen
See
https://github.com/davidkarlsen/hibernate-validator/tree/HV-448 (never mind the
naming of the branch - it was an old one - but changed to fit this issue).
I get
{noformat}
javax.validation.ValidationException: Unable to initialize
org.hibernate.validator.constraints.impl.SizeValidatorForString
at
org.hibernate.validator.engine.ConstraintTree.initializeConstraint(ConstraintTree.java:444)
at
org.hibernate.validator.engine.ConstraintTree.createAndInitializeValidator(ConstraintTree.java:346)
at
org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:317)
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.validateConstraint(ValidatorImpl.java:473)
at
org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:395)
at
org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:376)
at
org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:315)
at
org.hibernate.validator.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:634)
at
org.hibernate.validator.engine.ValidatorImpl.validateCascadedMethodConstraints(ValidatorImpl.java:532)
at
org.hibernate.validator.engine.ValidatorImpl.validateReturnValueForGroup(ValidatorImpl.java:1156)
at
org.hibernate.validator.engine.ValidatorImpl.validateReturnValueInContext(ValidatorImpl.java:1074)
at
org.hibernate.validator.engine.ValidatorImpl.validateReturnValue(ValidatorImpl.java:247)
at
org.hibernate.hv448.ValidationAspect.validateReturnedValue(ValidationAspect.java:129)
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
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:603)
at
org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:58)
at
org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:51)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy16.proceedOkWithDefinedArg(Unknown Source)
at
org.hibernate.hv448.ValidationAspectTest.proceedOkWithDefinedArg(ValidationAspectTest.java:46)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at
org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at
org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at
org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException: $Proxy22 cannot be cast to
javax.validation.constraints.Size
at
org.hibernate.validator.constraints.impl.SizeValidatorForString.initialize(SizeValidatorForString.java:30)
at
org.hibernate.validator.engine.ConstraintTree.initializeConstraint(ConstraintTree.java:441)
... 59 more
{noformat}
when validating with a composed constraint.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira