-->
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: error from loading hibernate.cfg.xml
PostPosted: Sat Feb 19, 2005 7:11 pm 
Newbie

Joined: Sat Feb 19, 2005 6:48 pm
Posts: 1
hi, I am new to hibernate, I am using hibernate 2.1, I got erros when I tried to load the hibernate.cfg.xml using following code, I have already been working on this for 10+hours, any help will be really appreciated.

Configuration cfg = new Configuration();
cfg.addResource("/WEB-INF/hibernate.cfg.xml");
cfg.addClass(ca.ut.lms.hibernate.model.TCourse.class);
cfg.addClass(ca.ut.lms.hibernate.model.TUser.class);
sessionFactory = cfg.buildSessionFactory();


my hibernate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/oplms</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="show_sql">false</property>
<!-- oplms mapping files. -->

<!-- <mapping resource="ca/ut/lms/hibernate/model/TCourse.hbm.xml" />
<mapping resource="ca/ut/lms/hibernate/model/TUser.hbm.xml" />
-->
</session-factory>

</hibernate-configuration>

This is the error:


javax.servlet.ServletException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778)
org.apache.jsp.secure.welcome_jsp._jspService(welcome_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)


root cause

java.lang.ExceptionInInitializerError
ca.ut.lms.hibernate.model.base.HibernateUtil.<clinit>(HibernateUtil.java:50)
ca.ut.lms.hibernate.model.dao.UserDAO.<init>(UserDAO.java:28)
org.apache.jsp.secure.welcome_jsp._jspService(welcome_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 21, 2005 2:41 am 
Newbie

Joined: Mon May 10, 2004 9:14 pm
Posts: 12
You can take a try like this
Code:
Configuration cfg = new Configuration();
cfg.addResource("/hibernate.cfg.xml");
cfg.addClass(ca.ut.lms.hibernate.model.TCourse.class);
cfg.addClass(ca.ut.lms.hibernate.model.TUser.class);
sessionFactory = cfg.buildSessionFactory();



or modify you cfg.xml file


Code:
Configuration conf = new Configuration().configure("/hibernate_rsys.cfg.xml");
sessionFactory = cfg.buildSessionFactory();
then you need not use cfg.addClass


modify your cfg.xml file like this
Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/oplms</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="show_sql">false</property>
<!-- oplms mapping files. -->

<mapping resource="ca/ut/lms/hibernate/model/TCourse.hbm.xml" />
<mapping resource="ca/ut/lms/hibernate/model/TUser.hbm.xml" />

</session-factory>

</hibernate-configuration>


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.