Hello,
I have a rich client which calls a session bean to search some data. The session bean validates the input, and I want to pass the validation result back to the client. I do not want to pass the interpolated messages, since the server does not know which language the client should show. Also, to highlight the correct field in the UI, I need the path of the validated value. I tried to throw a ConstraintViolationException in the session bean:
Code:
Set<ConstraintViolation<SearchInput>> result = validator.validate(searchInput);
if (!result.isEmpty()) {
throw new ConstraintViolationException(result);
}
But that doew not even compile, since the ConstraintViolationException requires a Set<ConstraintViolation<?>> and the validator result is a Set<ConstraintViolation<SearchInput>>.
My next try was to create my own exception:
Code:
Set<ConstraintViolation<SearchInput>> result = validator.validate(searchInput);
if (!result.isEmpty()) {
throw new SuchprofilValidationException(result);
}
But that still fails, because some part of the ConstraintViolationImpl is not serializable:
Code:
Caused by: java.io.NotSerializableException: org.hibernate.validator.util.annotationfactory.AnnotationProxy : The EJB specification restricts remote interfaces to only serializable data types. This can be disabled for in-vm use with the openejb.localcopy=false system property.
at org.apache.openejb.core.ivm.BaseEjbProxyHandler.copyObj(BaseEjbProxyHandler.java:504)
at org.apache.openejb.core.ivm.BaseEjbProxyHandler.copy(BaseEjbProxyHandler.java:301)
at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:285)
at $Proxy70.passendeStellenangeboteSuchen(Unknown Source)
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)
... 9 more
Caused by: java.io.NotSerializableException: org.hibernate.validator.util.annotationfactory.AnnotationProxy
How can I pass the validation result to the client? Creating my own java beans for the constraint violations and copying the values seems like a very bad solution to me.