-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cant get Hibernate Tools generated DAO code to run in Tomcat
PostPosted: Tue Jun 20, 2006 5:42 am 
Newbie

Joined: Tue May 23, 2006 4:32 am
Posts: 1
I generated, using hibernate tools 3.1.0 b5 my POJOs and the DAO code.

I really want to give these DAOs a shot, because as far as I understand, I don't need to implement a HibernateUtil class anymore.

Wether I use tomcat or JBoss, I always get a "Could not locate SessionFactory in JNDI" error in the console.

The following line triggers the exception :

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

I have the following in my Hibernate.cfg.xml :

<?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.bytecode.use_reflection_optimizer">false</property>
<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:3306/cargo?autoReconnect=true</property>
<property name="hibernate.connection.username">***</property>
<property name="hibernate.default_catalog">cargo</property>
<property name="hibernate.default_schema">cargo</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.session_factory_name">java:hibernate/SessionFactory</property>
<mapping resource="ch/infolearn/cargo/Crate.hbm.xml" />
<mapping resource="ch/infolearn/cargo/Container.hbm.xml" />
<mapping resource="ch/infolearn/cargo/Company.hbm.xml" />
<mapping resource="ch/infolearn/cargo/Boat.hbm.xml" />
</session-factory>
</hibernate-configuration>

I guess it's something to configure in Tomcat, but I've looked everywhere and just cant find the answer.

See below for more info, and thanks in advance if someone can help.

Hibernate version:
3.0.5

Mapping documents:
the ones generated by default


Code between sessionFactory.openSession() and session.close():


The exception occurs before, on this instruction in the DAO code :

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


Full stack trace of any exception that occurs:

java.lang.IllegalStateException: Could not locate SessionFactory in JNDI
ch.infolearn.cargo.CompanyHome.getSessionFactory(CompanyHome.java:30)
ch.infolearn.cargo.CompanyHome.<init>(CompanyHome.java:22)
org.apache.jsp.db.company_jsp._jspService(org.apache.jsp.db.company_jsp:51)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)


Name and version of the database you are using:
mysql 5

The generated SQL (show_sql=true):
n/a

Debug level Hibernate log excerpt:
debug


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 6:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the dao's currently is tied into running in a jndi enabled environment - we should change that.

_________________
Max
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.  [ 2 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.