-->
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.  [ 1 post ] 
Author Message
 Post subject: Error: Name [SessionFactory] is not bound in this Context
PostPosted: Mon Jun 04, 2012 12:57 pm 
Newbie

Joined: Fri Jun 01, 2012 4:02 pm
Posts: 2
I'm new to hibernate. I'm running hibernate 4.1.3 and Tomcat 7.0.27

I'm auto-generating DAO's with hibernate, and these DAO's contain this code:

Code:
   
protected SessionFactory getSessionFactory() {
      try {
         return (SessionFactory) new InitialContext()
               .lookup("SessionFactory");
      } catch (Exception e) {
         log.error("Could not locate SessionFactory in JNDI", e);
         throw new IllegalStateException(
               "Could not locate SessionFactory in JNDI");
      }
   }


My hibernate config contains this:

Code:
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.pool_size">20</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>


I'm receiving this error:

Code:
SEVERE: Could not locate SessionFactory in JNDI
javax.naming.NameNotFoundException: Name [SessionFactory] is not bound in this Context. Unable to find [SessionFactory].


I would like to leave the DAO's as they were created, without modification.

How do I configure my application so that it finds the default SessionFactory?

Any help would be appreciated, thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.