I have Eclipse Europa and am trying to do a hibernate example in it.
I am trying to simply add an entry to the database.
My hibernate.cfg.xml file is as follows:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!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">org.derby.Driver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/myDB</property>
<property name="hibernate.connection.username">me</property>
<property name="hibernate.connection.password">mine</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="Job.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Eclipse keeps showing errors for this xml.
An when I run the class with the hibernate code it shows/throws the following error.
Code:
Nov 15, 2009 12:24:58 AM org.slf4j.impl.JCLLoggerAdapter info
INFO: Hibernate 3.3.0.CR1
Nov 15, 2009 12:24:59 AM org.slf4j.impl.JCLLoggerAdapter info
INFO: hibernate.properties not found
Nov 15, 2009 12:24:59 AM org.slf4j.impl.JCLLoggerAdapter info
INFO: Bytecode provider name : cglib
Nov 15, 2009 12:24:59 AM org.slf4j.impl.JCLLoggerAdapter info
INFO: using JDK 1.4 java.sql.Timestamp handling
Nov 15, 2009 12:25:00 AM org.slf4j.impl.JCLLoggerAdapter info
INFO: configuring from resource: /hibernate.cfg.xml
Nov 15, 2009 12:25:00 AM org.slf4j.impl.JCLLoggerAdapter info
INFO: Configuration resource: /hibernate.cfg.xml
Nov 15, 2009 12:25:00 AM org.slf4j.impl.JCLLoggerAdapter error
[b]SEVERE: Error parsing XML: /hibernate.cfg.xml(2) The markup in the document preceding the root element must be well-formed.
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1505)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1439)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at AddJob.main(AddJob.java:19)
Caused by: org.dom4j.DocumentException: Error on line 2 of document : The markup in the document preceding the root element must be well-formed. Nested exception: The markup in the document preceding the root element must be well-formed.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1495)[/b] ... 3 more
Exception in thread "main" java.lang.NullPointerException
at AddJob.main(AddJob.java:34)
How do I get this resolved.
My java classes have no package hierarchy.
Is this problem due to Eclipse or is there an error in the xml.