Hi

This is a limitation of current implementation/bug
in org.apache.openejb.bval.BeanValidationAppendixInterceptor

On your side you can redefine the method you need in the interface and it
should work.

org.apache.openejb.bval.BeanValidationAppendixInterceptor#aroundInvoke
should consider the method actually called and not the EJB one if the
method is not defined inside.

I dont know if it will get fixed since this feature was removed from tomee
7 cause it is now a standard feature.

What you can easily do is fork our interceptor to write your own (it would
be easier since you dont need the cast and reflection we do to support bval
and hibernate-validator + you can inject the validator directly).

Should be close to https://gist.github.com/rmannibucau/1bbfce063bcf02c9d1c9

Issue is then not sure spring base classes are proxiable

personally and since you already use the bridge *you* have to impl I would
add this code in the handler (org.superbiz.dynamic.SpringDataProxy). It is
almost 1-1 to do around the line:

return method.invoke(repository.get(), args);

Romain
Le 7 juin 2015 14:02, "sansp00" <[email protected]> a écrit :

> I have built a simple app using 'merging' the Tomee example for
> spring-data-proxy-meta example and rest-example-with-application. I rely
> heavily on bean validation for my beans so I added the following property
> in
> my jUnit tests
> p.setProperty(BeanContext.USER_INTERCEPTOR_KEY,
> BeanValidationAppendixInterceptor.class.getName());
> And my spring data repository proxy throws an exception ... Removing the
> prop disables the bean validation, but the spring data proxy works
> properly.
> Here is a sample of the exception I get ...
> Caused by: javax.validation.ValidationException: can't call method
> validateParameters on
> org.apache.bval.jsr303.extensions.MethodValidatorImpl@7e744f43
>         at
>
> org.apache.openejb.bval.BeanValidationAppendixInterceptor.call(BeanValidationAppendixInterceptor.java:173)
>         at
>
> org.apache.openejb.bval.BeanValidationAppendixInterceptor.aroundInvoke(BeanValidationAppendixInterceptor.java:99)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:483)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
>         at
>
> org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:483)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
>         at
>
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
>         at
>
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
>         at
>
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
>         at
>
> org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
>         at
>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:322)
>         ... 59 more
> Caused by: java.lang.reflect.InvocationTargetException
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:483)
>         at
>
> org.apache.openejb.bval.BeanValidationAppendixInterceptor.call(BeanValidationAppendixInterceptor.java:170)
>         ... 81 more
> Caused by: javax.validation.ValidationException: Method public abstract
> java.lang.Object
> org.springframework.data.repository.CrudRepository.save(java.lang.Object)
> doesn't belong to class interface foo.bar.repository.MyRepositoryDAO
>         at
>
> org.apache.bval.jsr303.extensions.MethodValidatorImpl.validateParameters(MethodValidatorImpl.java:88)
>         ... 86 more
>
> Is this a bug, a limitation or something I might be doing wrong ? Any
> workarounds, I really want to combine both things in my app.
>
> Thanks in advance
> Patrick
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Using-Spring-Data-and-bean-validation-in-Tomee-1-7-2-exception-tp4675192.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Reply via email to