Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Hibernate Validator 3.1 ignoring messages from bundle
PostPosted: Thu Jun 14, 2012 3:58 pm 
Newbie

Joined: Thu Jun 14, 2012 3:48 pm
Posts: 2
I'm using Hibernate Validator 3.1.0.GA. It is not looking up custom messages from ValidationMessages.properties. Here is the example project:
Code:
git clone https://bitbucket.org/sstein/validation-example.git

To illustrate the problem, I created several test cases:
Code:
mvn test

One test case is failing with:
Code:
Failed tests: validateDescriptionTest(com.example.MyClassTest): expected:<[Description must be between 1 and 10 characters long.]> but was:<[#{descriptionMsg}]>

The field is annotated with:
Code:
@Length(min = 1, max = 10, message ="{descriptionMsg}")

And I got in src/main/resources/ValidationMessages.properties:
Code:
Description must be between 1 and 10 characters long.

I also tried moving the property file around, but without any luck.
Any idea what is going wrong here?


Top
 Profile  
 
 Post subject: Re: Hibernate Validator 3.1 ignoring messages from bundle
PostPosted: Fri Jun 15, 2012 4:22 am 
Hibernate Team
Hibernate Team

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

if you are using Hibernator Validator 3.x the properties file should be _ValidatorMessages.properties_ and not _ValidationMessages.properties_. By the way, is there a particular reason you are using 3.x? This code base is obsolete and there is no ongoing development in Validator 3. I highly recommend to switch to Validator 4.x (e.g. 4.3.0.Final) which implements the Bean Validation specification.

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate Validator 3.1 ignoring messages from bundle
PostPosted: Mon Jun 18, 2012 2:24 pm 
Newbie

Joined: Thu Jun 14, 2012 3:48 pm
Posts: 2
Indeed, after renaming the message bundle to ValidatorMessages.properties, everything is working as expected. Many thanks for spotting that!

Yes, it is a rather old version, but we are not in a project phase where replacing such a core library is a good idea. But if we have the opportunity, we will do so.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.