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 getting Session Factory - InitialContext
PostPosted: Fri Sep 24, 2010 1:24 pm 
Newbie

Joined: Fri Sep 24, 2010 1:15 pm
Posts: 1
I've been searching through various problems trying to solve the below error, to no success with the recommended strategies. I'm using the hibernate eclipse plugin and performing the reverse object creation from a reveng.xml file, and at one point not that long ago, everything was working fine - a few changes (that weren't hibernate related!) later, and I now get the below issue. I'm relatively certain it has to be some sort of configuration issue, I just can't figure out what:

Error: SEVERE: Could not locate SessionFactory in JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

I have no desire to have a specific session factory or use specify JNDI, and per the posts I've seen, you just don't put in the session-factory name in your config file -- which I've done (and had previously already):

<?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.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.password">letmein</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/wwa</property>
<property name="hibernate.connection.username">test</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<mapping resource="com/brighttiger/wwa/data/client/Program.hbm.xml" />
<mapping resource="com/brighttiger/wwa/data/client/Collection.hbm.xml" />
</session-factory>
</hibernate-configuration>

The DAO object created the following code to perform the following to create the session:

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");
}
}

Looking up the new initial context is where everything goes haywire at. Additionally, I can configure and successfully use the hibernate console in eclipse to perform HQL queries/etc without issue. This leaves me at a dead end as to just what it is I broke along the way. Any help is 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.