-->
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.  [ 4 posts ] 
Author Message
 Post subject: HHH000206 why and when
PostPosted: Thu Apr 21, 2016 5:01 am 
Newbie

Joined: Thu Apr 21, 2016 4:39 am
Posts: 2
A possibly naive question by a first-time user: how can I get Hibernate to find "hibernate.properties"?
I placed it almost everywhere, first of all in the directory specified by java property "user.dir", then I added entries to "java.class.path" property, with no avail, finally I put that file in directories from PATH and CLASSPATH environment variables.
In documentation there is a reference to java classpath, however "hibernate.properties" is not a jar, after all.
Could anyone provide more information or a working example?
I understand it is not a mandatory file, but if I can't have Hibernate finding it, I believe to be lacking some serious knowledge.
Thanks in advance


Top
 Profile  
 
 Post subject: Re: HHH000206 why and when
PostPosted: Thu Apr 21, 2016 5:37 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The easiest way is to embed it in your jar or just add it in src/main/resources if you're using Maven


Top
 Profile  
 
 Post subject: Re: HHH000206 why and when
PostPosted: Thu Apr 21, 2016 5:58 am 
Newbie

Joined: Thu Apr 21, 2016 4:39 am
Posts: 2
Yes, I understand. In the meantime I downloaded version 4.3.11 (the site where I am working is using 4.3.10).
A look at the source code showed that ConfigHelper actually invokes a ClassLoader.
Since there is a fallback strategy in the same method, one may wonder why the definition of a property file outside any jar is not supported.


Top
 Profile  
 
 Post subject: Re: HHH000206 why and when
PostPosted: Thu Apr 21, 2016 3:55 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Hibernate tries to locate it like this:

Code:
InputStream stream = ConfigHelper.getResourceAsStream( "/hibernate.properties" );


So the file can be located only if it's in the root of the current classpath, either in a jar or externally.


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