-->
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.  [ 8 posts ] 
Author Message
 Post subject: Custom Validator.properties file
PostPosted: Wed Aug 08, 2007 11:26 am 
Newbie

Joined: Wed Aug 08, 2007 7:57 am
Posts: 4
Hi

I want to implement hibernate validator for my project.I put in my custom ValidatorMessage.properties file in the root directory but when save or update is done it checks for the default properties file in the jar file.
I am using spring-hibernate 3.2.0.5 jar .

where should i put my properties file and what should i do to make the session factory take ccustom properties file rather than default one.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 2:24 pm 
Newbie

Joined: Wed Aug 08, 2007 7:57 am
Posts: 4
Please help me with this


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 9:51 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't know what spring-hibernate.jar is but it does work fine with the standard distribution.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 1:37 pm 
Newbie

Joined: Wed Aug 08, 2007 7:57 am
Posts: 4
emmanuel wrote:
I don't know what spring-hibernate.jar is but it does work fine with the standard distribution.


Hi

when u create session factory using the org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean ,what property or file you would have to mention or change to let the session factory know where it must find the base name for the resource bundle.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 6:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
As long as the thread context ClassLoader used to build the SF see ValidatorMessages.properties at the root level, you're fine.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 9:31 am 
Newbie

Joined: Wed Aug 08, 2007 7:57 am
Posts: 4
emmanuel wrote:
As long as the thread context ClassLoader used to build the SF see ValidatorMessages.properties at the root level, you're fine.


Hi

I tried that ,putting the validatorMessages.properties in the root directory . It dint work.It takes the default property file stored in the jar file.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 11:01 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Here is the code

Code:
private ResourceBundle getDefaultResourceBundle() {
      ResourceBundle rb;
      try {
         //use context class loader as a first citizen
         ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
         if ( contextClassLoader == null ) {
            throw new MissingResourceException( "No context classloader", null, VALIDATOR_MESSAGE );
         }
         rb = ResourceBundle.getBundle(
               VALIDATOR_MESSAGE,
               Locale.getDefault(),
               contextClassLoader
         );
      }
      catch (MissingResourceException e) {
         log.trace( "ResourceBundle " + VALIDATOR_MESSAGE + " not found in thread context classloader" );
         //then use the Validator Framework classloader
         try {
            rb = ResourceBundle.getBundle(
                  VALIDATOR_MESSAGE,
                  Locale.getDefault(),
                  this.getClass().getClassLoader()
            );
         }
         catch (MissingResourceException ee) {
            log.debug(
                  "ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to " + DEFAULT_VALIDATOR_MESSAGE
            );
            //the user did not override the default ValidatorMessages
            rb = null;
         }
      }
      isUserProvidedResourceBundle = true;
      return rb;
   }

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 11:02 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
VALIDATOR_MESSAGE is the file name we discussed. So you have a classloader mess somewhere.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.