-->
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: hibernate.properties not found AND Problem setting prop type
PostPosted: Fri Jun 04, 2004 1:16 pm 
Beginner
Beginner

Joined: Fri Jun 04, 2004 12:50 pm
Posts: 32
Hi all,

I have tried to find the solution to this problem which I am sure is out there somewhere.

I am using hibernate 2.1. I am trying to use it inside of JBoss although not using the hibernate that comes with JBoss. The jar that contains my .class, .jar and .hbm.xml files also contains my hibernate.properties file. If I understand correctly this file only needs to be in the classpath and not in a specific location. I am putting the jars in the server/default/deploy directory on the jboss server.

Well, when I try to create an object it gives me this error

......
2004-06-02 20:55:04,089 INFO [com.camp.server.menu.dm.dm_menu] Creating dm_general
2004-06-02 20:55:04,151 INFO [net.sf.hibernate.cfg.Environment] Hibernate 2.1.3
2004-06-02 20:55:04,170 INFO [net.sf.hibernate.cfg.Environment] hibernate.properties not found
2004-06-02 20:55:04,177 INFO [net.sf.hibernate.cfg.Environment] using CGLIB reflection optimizer
2004-06-02 20:55:04,199 INFO [net.sf.hibernate.cfg.Configuration] Mapping resource: com/camp/common/menu/Menu.hbm.xml
2004-06-02 20:55:04,226 DEBUG [net.sf.hibernate.util.DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
2004-06-02 20:55:04,228 DEBUG [net.sf.hibernate.util.DTDEntityResolver] found http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
2004-06-02 20:55:04,494 INFO [net.sf.hibernate.cfg.Binder] Mapping class: com.camp.common.menu.Menu -> tblMenu
2004-06-02 20:55:04,927 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: menu_id -> id_menu, type: integer
2004-06-02 20:55:04,994 DEBUG [net.sf.hibernate.cfg.Binder] Mapped property: menu_name -> name, type: string
2004-06-02 20:55:04,995 ERROR [net.sf.hibernate.cfg.Configuration] Could not compile the mapping document
net.sf.hibernate.MappingException: Problem trying to set property type by reflection
at net.sf.hibernate.mapping.SimpleValue.setTypeByReflection(SimpleValue.java:183)
at net.sf.hibernate.cfg.Binder.createProperty(Binder.java:1057)

.......
.....

A few things.

1. It cannot find hibernate.properties. I have put this file into multiple locations but it just will not be found.

2. Why is it trying to locate http://hibernate.sourceforge.net

3. I notice that some people use properties.hbm.xml instead of the plain text hibernate.properties. Is there a reason for that and should I be using the xml version?

4. Should the jar with the hibernate.properties file in it be in the server/default/lib directory on the JBoss server instead of the server/default/deploy

5. The above errors are run with the code below. As can be seen, because of my frustration I added the properties in manually to try and get stuff to work. That is why it all seems to work and only gives a problem with the reflection. Any ideas as to what is causing the reflection problem would be appreciated.




public dm_menu(String _menu_name) throws Exception {
log.info("Creating dm_general");

// query to issue
String query =
"select * from menu "
+ "in class com.camp.common.menu.Menu "
+ "where lower(menu.name)=lower(:name)";

// search for what?
String name = _menu_name;

// init
Configuration cfg = new Configuration()
.addClass(Menu.class);

cfg.setProperty("hibernate.connection.username","postgres");
cfg.setProperty("hibernate.connection.password","");
cfg.setProperty("hibernate.connection.url","jdbc:postgresql://localhost/camp");
cfg.setProperty("hibernate.connection.driver_class","org.postgresql.Driver");
cfg.setProperty("hibernate.dialect","net.sf.hibernate.dialect.HSQLDialect");

SessionFactory sf = cfg.buildSessionFactory();

// open session
Session sess = sf.openSession();

// search and return
List list = sess.find(query, name,
Hibernate.STRING);

if (list.size() == 0) {
System.out.println("No products named "
+ name);
System.exit(0);
}
Menu m = (Menu) list.get(0);
sess.close();
System.out.println("Found product: " + m);

}

Any help on any of this would be awesome. Thanks so much. If ther are other sources that I should have looked at the links to those instead would
also be great.

Cheers

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 1:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
1) In your setup, the properties file should be in the root (i.e., no path within the jar) of the jar file
2) To locate DTDs. Hibernate's entity resolver, however actually resolves this reference locally using the classpath (as you can clearly see in the logs)
3) http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-xmlconfig. Generally people like to use (well designed) XML files for config over prop files. The xml config also lets you declare you mappings, which is not available in the props file
4) No idea. You probably want to consult the JBoss docs.


Top
 Profile  
 
 Post subject: Re: hibernate.properties not found AND Problem setting prop
PostPosted: Sat Jun 05, 2004 7:41 am 
Beginner
Beginner

Joined: Thu May 13, 2004 5:51 am
Posts: 28
tomansley wrote:

5. That is why it all seems to work and only gives a problem with the reflection. Any ideas as to what is causing the reflection problem would be appreciated.

You are getting a MappingException, which implies there is something screwy in your OR mappings. Try and check your Menu.hbm.xml or paste it out.

--


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 3:10 am 
Newbie

Joined: Sun Jun 06, 2004 2:53 am
Posts: 1
Location: Sydney, Australia
Tom,

I am not expert to this but I was curious as to why you have the Dialect set to HSQL rather than PosrgresSQL?

cfg.setProperty("hibernate.dialect","net.sf.hibernate.dialect.HSQLDialect");

Jerry


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.