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.  [ 8 posts ] 
Author Message
 Post subject: Error in parsing hibernate.cfg.xml
PostPosted: Mon May 24, 2004 8:43 am 
Newbie

Joined: Mon May 24, 2004 6:07 am
Posts: 6
Hi

I try to use hibernate, but I always get following error (some error with the DTD sheme) when I try to configure hibernate:

Configuration cfg = new Configuration().configure ("/resources/hibernate.cfg.xml");

->
0 [main] INFO net.sf.hibernate.cfg.Environment - Hibernate 2.1.1
0 [main] INFO net.sf.hibernate.cfg.Environment - hibernate.properties not found
0 [main] INFO net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
15 [main] INFO net.sf.hibernate.cfg.Configuration - configuring from resource: /resources/hibernate.cfg.xml
15 [main] INFO net.sf.hibernate.cfg.Configuration - Configuration resource: /resources/hibernate.cfg.xml
78 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath under net/sf/hibernate/
net.sf.hibernate.HibernateException: problem parsing configuration/resources/hibernate.cfg.xml
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:906)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:845)
at ch.ejpd.jdbkof.client.testClient.<init>(testClient.java:56)
at ch.ejpd.jdbkof.client.testClient.main(testClient.java:85)
Caused by: org.dom4j.DocumentException: Error on line 3 of document : java.lang.NullPointerException Nested exception: java.lang.NullPointerException
at org.dom4j.io.SAXReader.read(SAXReader.java:355)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:901)
... 3 more
78 [main] ERROR net.sf.hibernate.cfg.Configuration - problem parsing configuration/resources/hibernate.cfg.xml
org.dom4j.DocumentException: Error on line 3 of document : java.lang.NullPointerException Nested exception: java.lang.NullPointerException
at org.dom4j.io.SAXReader.read(SAXReader.java:355)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:901)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:845)
at ch.ejpd.jdbkof.client.testClient.<init>(testClient.java:56)
at ch.ejpd.jdbkof.client.testClient.main(testClient.java:85)
Nested exception:
java.lang.NullPointerException
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:658)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:901)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:845)
at ch.ejpd.jdbkof.client.testClient.<init>(testClient.java:56)
at ch.ejpd.jdbkof.client.testClient.main(testClient.java:85)

My config doc:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>

<!--Mapping files -->
<mapping resource="DTOSystemInfo.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Whats wrong ... (I am using jdk 1.4.2_02 with eclipse, hibernate 2.1.3)

Thanks very much


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 9:13 am 
Beginner
Beginner

Joined: Fri May 21, 2004 3:49 pm
Posts: 21
Location: Germany, Mainz
Hum, okay the cfg-file doesn't contain any erros, it seems to lie
somewhere else, but till yet I can't tell you where.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 11:19 am 
Newbie

Joined: Tue May 11, 2004 11:24 pm
Posts: 5
Ok, at a rough guess:

you don't need to configure the hibernate.cfg.xml file - that is, no need to do:

Configuration cfg = new Configuration().configure ("/resources/hibernate.cfg.xml");

Instead, you might want to do this:

Configuration cfg = new Configuration().configure ("package-it-is-in.DTOSystemInfo.hbm.xml");
And then

SessionFatory sf = cfg.buildSessionFactory();

Which I assume is what you are trying to do - build a session factory.

ANYWAY, you'll want to make sure that your files are in the proper places (which is hard to tell you seeing as I don't know what server are using etc).

By the way, you'll want to make sure that the DTOSystemInfo.hbm.xml is in a folder that is in your classpath (ie a package).

Uh, you might also want to add some configuration details to your hibernate.cfg.xml file -> such as shown in the hibernate manual, page 18.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 11:44 am 
Newbie

Joined: Mon May 24, 2004 6:07 am
Posts: 6
Hi thanks for your answer

Unfortunaltely it dosen't help: If I make something like

Configuration cfg = new Configuration().configure("/SysInfo.hbm.xml");

I get the same Exception. I think there is someting wrong with the parsing (DTD Sheme ?)

running
0 [main] INFO net.sf.hibernate.cfg.Environment - Hibernate 2.1.3
32 [main] INFO net.sf.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.ehcache.hibernate.Provider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.hbm2ddl.auto=create, hibernate.connection.url=jdbc:mysql://localhost/jdbkof, hibernate.show_sql=true, hibernate.connection.password=password, hibernate.connection.pool_size=5}
32 [main] INFO net.sf.hibernate.cfg.Environment - using java.io streams to persist binary types
32 [main] INFO net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
47 [main] INFO net.sf.hibernate.cfg.Configuration - configuring from resource: /SysInfo.hbm.xml
47 [main] INFO net.sf.hibernate.cfg.Configuration - Configuration resource: /SysInfo.hbm.xml
110 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
125 [main] ERROR net.sf.hibernate.cfg.Configuration - problem parsing configuration/SysInfo.hbm.xml
org.dom4j.DocumentException: Error on line 4 of document : java.lang.NullPointerException Nested exception: java.lang.NullPointerException
at org.dom4j.io.SAXReader.read(SAXReader.java:355)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:930)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:874)
at demo.DemoMain.<init>(DemoMain.java:30)
at demo.DemoMain.main(DemoMain.java:39)
Nested exception:
java.lang.NullPointerException
at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
at org.apache.crimson.parser.Parser2.parse(Unknown Source)
at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:930)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:874)
at demo.DemoMain.<init>(DemoMain.java:30)
at demo.DemoMain.main(DemoMain.java:39)
net.sf.hibernate.HibernateException: problem parsing configuration/SysInfo.hbm.xml
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:935)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:874)
at demo.DemoMain.<init>(DemoMain.java:30)
at demo.DemoMain.main(DemoMain.java:39)
Caused by: org.dom4j.DocumentException: Error on line 4 of document : java.lang.NullPointerException Nested exception: java.lang.NullPointerException
at org.dom4j.io.SAXReader.read(SAXReader.java:355)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:930)
... 3 more


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 12:11 pm 
Newbie

Joined: Tue May 11, 2004 11:24 pm
Posts: 5
Ok, so you test this:
Configuration cfg = new Configuration().configure("/SysInfo.hbm.xml");

And in the errors, you get this error:
...
125 [main] ERROR net.sf.hibernate.cfg.Configuration - problem parsing configuration/SysInfo.hbm.xml
...

Which indicates that it can't seem to parse these files. Does SysInfo.hbm.xml exist? I'd assume so - but is it in a package?

that is, if your directory structure is:
C:\hibernateStuff\test1\SysInfo.hbm.xml

Then is
C:\hibernateStuff\ in your classpath?
And if it is, then see if
Configuration cfg = new Configuration().configure("test1.SysInfo.hbm.xml");
works - you'll want to make sure that there is an accompanying SysInfo.java POJO that is marked as package test1 and is in the
C:\hibernateStuff\test1\ directory.

And of course, you'll want to make sure that the hbm.xml file correctly maps the data in the pojo to the database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 2:39 am 
Newbie

Joined: Mon May 24, 2004 6:07 am
Posts: 6
Hi

It seem everything is OK. I think that must be am problem with following line in the xml-File

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

the parser can't find the http://hibernate.sourceforge.net/hibern ... on-2.0.dtd. If I chekc the file with the xmlspy, everything works fine!

The xml-parser find all documents. If I put some garbage in front of the file, the parser stopps there.

I don't have any idea what's wrong.

I try to debugg ...

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 4:09 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Show your mapping file SysInfo.hbm.xml


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:07 am 
Newbie

Joined: Mon May 24, 2004 6:07 am
Posts: 6
Here is my mapping file

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"file:///D://Projekte//JDBKof//Prototypen//hibernate//bin//hibernate-mapping-2.0.dtd">
<hibernate-mapping package="org.hibernate.admin.model">
<class name="demo.SystemInfo" table="systeminfo">
<id name="id" column="id" type="int">
<generator class="increment"/>
</id>
<property name="topic" type="timestamp" column="topic"/>
<property name="message" type="string" column="message"/>
</class>
</hibernate-mapping>

I replaced http://hibernate.sourceforge.net/hibern ... on-2.0.dtd with file:///D://Projekte//JDBKof//Prototypen//hibernate//bin//hibernate-mapping-2.0.dtd then the parsinf work.
Unfortunately I got a ExceptionInInitializerError with the cache provider:

1015 [main] INFO net.sf.hibernate.cfg.Configuration - instantiating and configuring caches
java.lang.ExceptionInInitializerError
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:739)
at demo.DemoMain.<init>(DemoMain.java:33)
at demo.DemoMain.main(DemoMain.java:40)
Caused by: java.lang.IllegalStateException: Cannot determine classloader
at net.sf.cglib.core.AbstractClassGenerator.getClassLoader(AbstractClassGenerator.java:165)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:176)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:177)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:149)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:142)
at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:235)

Any idea?

Thank you very much


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