Hi,
I have been using hibernate for over a year now. Ihave developed an applicationusing Hibernate 3.0. I have deployed this application on Tomcat and left it there running. It worked fine till today (27th Septmeber 2006) afternoon. Basically it started giving me an exception as follows:
Caused by: org.hibernate.HibernateException: Could not parse configuration: /hib
ernate.cfg.xml
I could not understand the problem, and why it came out now!! I restarted tomcat several times, but still giave me the same exception. Thus I decided to compile the system again.
To my amazment neither on the development environment it wanted to work. It compiles fine, but when I run the web application it gave me the same EXACT exception.
I can not believe my eyes because untill this morning, the same application was working Just fine!!
I am connecting with Microsoft Sql Server 2000, but I also tried it with Microsoft Sql Server 2005 ... it did not work on both!!
Thanks for any replies.
Bormli
Please find the full exception trace below:
Code:
17:12:26,109 ERROR [STDERR] org.hibernate.HibernateException: Could not parse co
nfiguration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1376)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at com.company.cvmanager.util.HibernateUtil.<clinit>(Unknown Source)
at com.company.cvmanager.dao.DAOFactory.getSession(Unknown Source)
at com.company.cvmanager.dao.DAOFactory.getAccountDAO(Unknown Source)
at com.company.cvmanager.service.impl.BaseAccountService.findByUsernam
e(Unknown Source)
at com.company.cvmanager.actions.LoginAction.getAccount(Unknown Source
)
at com.company.cvmanager.actions.LoginAction.doLogin(Unknown Source)
at com.company.cvmanager.actions.LoginAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.dom4j.DocumentException: Connection reset Nested exception: Conne
ction reset
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1366)
... 34 more
17:12:26,125 ERROR [[action]] Servlet.service() for servlet action threw excepti
on
java.lang.ExceptionInInitializerError
at com.company.cvmanager.util.HibernateUtil.<clinit>(Unknown Source)
at com.company.cvmanager.dao.DAOFactory.getSession(Unknown Source)
at com.company.cvmanager.dao.DAOFactory.getAccountDAO(Unknown Source)
at com.company.cvmanager.service.impl.BaseAccountService.findByUsernam
e(Unknown Source)
at com.company.cvmanager.actions.LoginAction.getAccount(Unknown Source
)
at com.company.cvmanager.actions.LoginAction.doLogin(Unknown Source)
at com.company.cvmanager.actions.LoginAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.HibernateException: Could not parse configuration: /hib
ernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1376)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
... 32 more
Caused by: org.dom4j.DocumentException: Connection reset Nested exception: Conne
ction reset
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1366)
... 34 more
17:13:11,296 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resour
ce:log4j.xml
17:14:11,296 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resour
ce:log4j.xml
17:15:11,296 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resour
ce:log4j.xml
And this is my configuration file:
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="cvmgrSessionFactory">
<!-- SQL Server (Local) Connection properties -->
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="connection.url">jdbc:microsoft:sqlserver://localhost:1433;databaseName=cvmgr</property>
<property name="connection.username">cvmgr</property>
<property name="connection.password">password</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="show_sql">true</property>
<!-- mapping files -->
<mapping resource="com/company/cvmanager/common/impl/BaseAccount.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseResource.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseContact.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseAddress.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseEmployment.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseProject.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseSkillDefinition.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseSkill.hbm.xml"/>
<mapping resource="com/company/cvmanager/common/impl/BaseAnnotation.hbm.xml"/>
</session-factory>
</hibernate-configuration>
And the following is my util class used to get the session:
Code:
package com.company.cvmanager.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* Basic Hibernate helper class for Hibernate configuration and startup.
*
* @author Simon J. Aquilina
*
*/
public class HibernateUtil {
private static Configuration configuration;
private static SessionFactory sessionFactory;
static {
try {
// Karl: Instantiating the configuration object
configuration = new Configuration();
// Configure ORM from the default configuration file.
configuration.configure();
// Create the session factory.
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}
/**
* Returns the global SessionFactory.
*
* @return SessionFactory
*/
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}