Hi All:
I have used reveng.xml to generate DAO and VO Code for my Hibernate and Struts 1.2 Application within Eclipse 3.2 Using JBoss Hibernate Plugins.
However, my DAO Code is Useless as the following fails:
protected SessionFactory getSessionFactory()
{
try
{
return (SessionFactory) new InitialContext().lookup("java:comp/env/hibernate/SessionFactory");
}
catch (Exception e)
{
log.error("********Could not locate SessionFactory in JNDI", e);
}
return null;
}
I get the Following Exception:
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(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.dict.dao.WordMasterHome.getSessionFactory(WordMasterHome.java:36)
at com.dict.dao.WordMasterHome.<init>(WordMasterHome.java:29)
The following is my hibernate.cfg.xml File
<?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 name="SessionFactory">
<property name="hibernate.session_factory_name">java:comp/env/hibernate/SessionFactory</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dictionary</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.default_schema">dictionary</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="com/dict/dao/PartOfSpeechMaster.hbm.xml" />
<mapping resource="com/dict/dao/MeaningMaster.hbm.xml" />
<mapping resource="com/dict/dao/WordMaster.hbm.xml" />
</session-factory>
</hibernate-configuration>
which was also generated using the Plugins.
I am not able to get a Sessin Factory. This is so puzzling. Do I need a context.xml in META_INF or what ????
All help is appreciated.
Thanks.
Chetan
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html