It seems Weld proxy has the same annotations as the proxied
class. However this conflicts with Bean validation spec as far
as @Valid is concerned.
This section of the bean validation spec is ending up in
violation due to the duplicated annotation:
• One must not mark a method return value for cascaded
validation more than once in a line of a class hierarchy.
In other words, overriding methods on sub types (be it sub
classes/interfaces or interface implementations) cannot mark
the return value for cascaded validation if the return value
has already been marked on the overridden method of the super
type or interface.
"The @Valid annotation is used to declare that a cascaded
validation of the given method/constructor parameters or
return values is performed by the Bean Validation provider. "
Here is some debug added to the apache bean validation code
that shows which two classes have the @Valid on the
createValidEvent method:
$$$$$$$$$$$$DEBUG clazz = class
org.hibernate.beanvalidation.tck.tests.integration.cdi.executable.CalendarServiceWithCascadingReturnValue$Proxy$_$$_WeldSubclass
method = public
org.hibernate.beanvalidation.tck.tests.integration.cdi.executable.Event
org.hibernate.beanvalidation.tck.tests.integration.cdi.executable.CalendarServiceWithCascadingReturnValue$Proxy$_$$_WeldSubclass.createValidEvent()
$$$$$$$$$$$$DEBUG clazz = class
org.hibernate.beanvalidation.tck.tests.integration.cdi.executable.CalendarServiceWithCascadingReturnValue
method = public
org.hibernate.beanvalidation.tck.tests.integration.cdi.executable.Event
org.hibernate.beanvalidation.tck.tests.integration.cdi.executable.CalendarServiceWithCascadingReturnValue.createValidEvent()
$$$$$$$$$$$$$$$$$DEBUG returnValid = 2 // number of hits
having @Valid
If I understand correctly, I think this annotation needs to be
treated differently.