-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Validator + EJB Session Bean
PostPosted: Fri Oct 15, 2010 7:30 am 
Newbie

Joined: Fri Oct 15, 2010 7:18 am
Posts: 2
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.


Top
 Profile  
 
 Post subject: Re: Hibernate Validator + EJB Session Bean
PostPosted: Mon Oct 18, 2010 6:18 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

you are running probably into HV-291. I would assume you are using composed constraints. Which version of Validator are you using? With version 4.1.0.Final the issue should be fixed.

Remember though, you have to make sure that the objects you are validating are serializable as well.

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate Validator + EJB Session Bean
PostPosted: Mon Oct 18, 2010 10:32 am 
Newbie

Joined: Fri Oct 15, 2010 7:18 am
Posts: 2
Thank you, the new version of hibernate validator solved the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.