-->
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: Could not locate SessionFactory in JNDI
PostPosted: Wed Sep 20, 2006 10:36 pm 
Newbie

Joined: Wed Sep 20, 2006 10:15 pm
Posts: 12
Hi folks,

I noticed this question has been asked a couple of times, at least once in the Tools forum. Unfortunately none seems to fix my problem.

I am new to the whole Hibernate/Eclipse thing and decided to give it a try with Hibernate Tools. It's generated everything and I was trying to do a simple test by persisting a single object in the main() method:

Code:
Dog dog = new Dog();
dog.setName("Bob");
DogHome dogHome = new DogHome();
dogHome.persist(dog);


Unfortunately it failed in DogHome.getSessionFactory() method, on the line that says

Code:
return (SessionFactory)  new InitialContext().lookup("SessionFactory");


I'm relying on the tools too much at the moment to realise what is exactly going on under the bonnet (or hood...). Any suggestions or even pointers would be greatly appreciated.

Thanks,
Dany.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 21, 2006 12:50 am 
Newbie

Joined: Wed Sep 20, 2006 10:15 pm
Posts: 12
Please excuse replying to my own topic. I just noticed straight after the "Could not locate..." error message I got a NoInitialContextException.

Here's my sanitised hbm.xml file.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
        <property name="hibernate.connection.password"></property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/bernerline</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
    </session-factory>
</hibernate-configuration>


Any assistance would be greatly appreciated. Can't wait to start coding the app :o)

Thanks again,
Dany.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 21, 2006 8:23 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Do you have a JNDI provider running? I can't tell from your post.

You can set the name of the session factory by including/modifying the hibernate.session_factory_name property.
I.E. (in hibernate.properties)
Code:
hibernate.session_factory_name=MySessionFactory
OR (in .cfg.xml)
Code:
<property name="hibernate.session_factory_name">MySessionFactory</property>


Curtis ...

_________________
---- Don't forget to rate! ----


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.