I am a newbie to hibernate. I am doing the example specified in
www.hibernate.org and using oracle as the database.
When I run the program I get the error :
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.MappingException: Could not read mappings from resource: events/Event.hbm.xml
java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(Unknown Source)
at events.EventManager.createAndStoreEvent(Unknown Source)
at events.EventManager.main(Unknown Source)
Caused by: org.hibernate.MappingException: Could not read mappings from resource: events/Event.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:484)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1443)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1411)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1392)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1368)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1288)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
... 3 more
Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:430)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:481)
... 9 more
Caused by: org.dom4j.DocumentException: Error on line 2 of document : XML declaration may only begin entities. Nested exception: XML declaration may only begin entities.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:421)
... 10 more
Exception in thread "main"
----------------------------------------------------------------------------------
my hibernate.cfg.xml is :
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.Driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@172.17.8.52:1521:IFHT03</property>
<property name="hibernate.connection.datasource"> java:comp/env/jdbc/HibAppDS</property>
<property name="hibernate.connection.username">daweb_user</property>
<property name="hibernate.connection.password">daweb_user</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">select</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<mapping resource="events/Event.hbm.xml"/>
<class-cache class="/events/Event" region="Event" usage="read-write"/>
</session-factory>
</hibernate-configuration>
---------------------------------------------------------------------------------
and Event.hbm.xml is :
<?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="events.Event" table="EVENTS">
<id name="id" column ="EVENT_ID" type="integer"/>
<generator class="native"/>
</id>
<property name="dt" type="timestamp" column="EVENT_DATE"/>
<property name="title" column="TITLE"/>
</class>
</hibernate-mapping>
Can any one help me what causes these errors ?
Thanks,
JSV