The MethodValidator could not handle Proxied objects like in EJB environment

Description

Using the MethodValidator with proxied objects via an interceptor in an ejb environment throws the following exception:

javax.validation.ConstraintDeclarationException: Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints. The following method itself has no parameter constraints but it is not defined on a sub-type of class de.enexoma.smartmeter.server.facade.config.ResourceBundleFacadeBean: MethodMetaData [method=public abstract java.util.Map de.enexoma.smartmeter.server.facade.ResourceBundleFacade.get(java.lang.String) throws de.enexoma.smartmeter.server.error.EnexomaException, parameterMetaData=[ParameterMetaData [type=class java.lang.String], [index=0], name=arg0], constraints=[], isCascading=false]], constraints=[], isCascading=false, hasParameterConstraints=false]

The method in the "real" class has constraints defined:

public Map<Locale,List<ResourceBundle>> get(@NotNull @Size(min=1)final String appName)

Environment

linux, java 1.6.0_24, hibernate-validator-4.2.0.Beta2, JBoss-5.1.0.GA

Activity

Andrei SereaOctober 25, 2012 at 11:15 AM

This is not possible to do for no-interface-view kind of ejbs. This basically forces the existence of an interface for any ejb

Ingo BrüllMarch 23, 2011 at 10:24 AM

I moved the annotations to the interfaces and it works. Thank you!

Gunnar MorlingMarch 21, 2011 at 7:58 PM

Right, only the root method of an overridden method in an inheritance hierarchy may be annoted with parameter constraints. discusses the reason for this in detail. In case of a session bean the interface (if there is one) must be annotated as Kevin says (I think ResourceBundleFacade is the interface here).

If your situation is another one (I'm not sure how proxies/interceptors relate to the problem) a complete example demonstrating the issue would be very helpful.

Kevin PolletMarch 21, 2011 at 7:32 PM

Hi,

First of all thanks for testing Beta2

What do you mean by "real" class ? If it's the implementation class it's because you have annotated the implementation method ResourceBundleFacadeBean#get() and not the contract method ResourceBundleFacadeBean#get(). As of 4.2.0.Beta1 some changes have been made on method validation as you can see here HV-421. I think this issue is a duplicate of HV-448.

Hope this help.

Rejected

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Andrei Serea
Gunnar Morling
Ingo Brüll
Kevin Pollet

Components

Affects versions

Priority

Created March 21, 2011 at 3:24 PM
Updated October 25, 2012 at 11:15 AM
Resolved March 23, 2011 at 12:38 PM