-->
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.  [ 5 posts ] 
Author Message
 Post subject: Help: Can't Parse Configuration
PostPosted: Wed Jun 07, 2006 11:05 am 
Newbie

Joined: Wed Jun 07, 2006 10:42 am
Posts: 2
I've created a webapp as a war and placed the config file in the webapp's classes directory which is in the webapp. When the code builds a session factory, it throws an exception that it can't parse the configuration file. I've tried a few different config files, but the result is the same. I've also changed the package path in the code to a config file that doesn't exist, and hibernate throws an exception saying it can't find the file - so I assume it's finding it ok.

The webapp is deployed on Tomcat 5, and the JDK version it's compiled with is 1.5.0_06.

Do I have to do anything other than have the config file on the classpath?

TIA

Hibernate version:

3

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="event.AuthEvent" table="AUTH_EVENT">
<property name="artifact" column="ARTIFACT"/>
<property name="username" column="USER_NAME"/>
<property name="timestamp" type="date" column="TIMESTAMP"/>
</class>

</hibernate-mapping>

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

static {
try {
sessionFactory = new Configuration().configure("/data/config/hibernate.cfg.xml").buildSessionFactory();

} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

Full stack trace of any exception that occurs:

Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not parse configuration: /data/config/hibernate.cfg.xml

Name and version of the database you are using:

Oracle 10

The generated SQL (show_sql=true):

None

Debug level Hibernate log excerpt:

None


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 07, 2006 12:02 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:21 pm
Posts: 61
Location: Hannover
There are multiple reasons why the configuration file cannot be parsed, to check them I would suggest the following steps:
- Change the debug level of you're log4j.configuration, set org.hibernate to DEBUG
- Check if you're configuration is valid XML with an external tool
- Make sure all required jars for hibernate are in you're classpath

If this doens't help post again with more detailed logging.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 08, 2006 5:16 am 
Newbie

Joined: Wed Jun 07, 2006 10:42 am
Posts: 2
The debug I'm getting is:

Code:
297502 [http-8180-Processor2] INFO  org.hibernate.cfg.Environment <clinit> - Hibernate 3.1.3
297512 [http-8180-Processor2] INFO  org.hibernate.cfg.Environment <clinit> - hibernate.properties not found
297514 [http-8180-Processor2] WARN  org.hibernate.cfg.Environment <clinit> - could not copy system properties, system properties will be ignored
297518 [http-8180-Processor2] INFO  org.hibernate.cfg.Environment <clinit> - using CGLIB reflection optimizer
297520 [http-8180-Processor2] INFO  org.hibernate.cfg.Environment <clinit> - using JDK 1.4 java.sql.Timestamp handling
297683 [http-8180-Processor2] INFO  org.hibernate.cfg.Configuration configure - configuring from resource: /data/config/hibernate.cfg.xml
297685 [http-8180-Processor2] INFO  org.hibernate.cfg.Configuration getConfigurationInputStream - Configuration resource: /data/config/hibernate.cfg.xml
297779 [http-8180-Processor2] DEBUG org.hibernate.util.DTDEntityResolver resolveEntity - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
297780 [http-8180-Processor2] DEBUG org.hibernate.util.DTDEntityResolver resolveEntity - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not parse configuration: /data/config/hibernate.cfg.xml


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 10, 2006 4:29 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:21 pm
Posts: 61
Location: Hannover
Seems something to be wrong with you're DTD. Make sure the DTD is contained in you're classpath or the server you're running can access them via http.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 9:35 pm 
Newbie

Joined: Fri Jun 23, 2006 1:46 pm
Posts: 5
I've seen this type of error before when I had the hibernate JAR being loaded by the bootstrap class loader. I think there's a bug in DTDEntityResolver that can result in an NPE if the jar is loaded by the bootstrap class loader. Don't know how you could be causing that to happen with a web app though, unless you've got the hibernate jar in the JRE's System Extensions directory or something.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.