0
votes

I'm trying to use Java Hibernate. I tried to run the HelloWorld example from http://www.manning.com/bauer2/chapter2.pdf. But I have run into some trouble. The jar version I'm using is not the same as in the book. So, I have to get rid of the deprecated way of instantiating SessionFactory. The ant compile is successful but as you can see, when I ant run, I get the following exception.

C:\_Java Hibernate>ant run
Buildfile: C:\_Java Hibernate\build.xml
clean:
[delete] Deleting directory
C:\_Java Hibernate\bin
[mkdir] Created dir: C:\_Java Hibernate\bin
compile:
[javac] Compiling 3 source files to C:\_Java Hibernate\bin
copymetafiles: [copy] Copying 3 files to C:\_Java Hibernate\bin
run:
[java] Mar 31, 2012 3:09:04 PM org.hibernate.annotations.common.Version
[java] INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
[java] Mar 31, 2012 3:09:04 PM org.hibernate.Version logVersion
[java] INFO: HHH000412: Hibernate Core {4.1.1}
[java] Mar 31, 2012 3:09:04 PM org.hibernate.cfg.Environment
[java] INFO: HHH000206: hibernate.properties not found
[java] Mar 31, 2012 3:09:04 PM org.hibernate.cfg.Environment buildBytecodeP rovider
[java] INFO: HHH000021: Bytecode provider name : javassist
[java] Mar 31, 2012 3:09:04 PM org.hibernate.cfg.Configuration configure
[java] INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
[java] Mar 31, 2012 3:09:04 PM org.hibernate.cfg.Configuration getConfigura tionInputStream
[java] INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at persistence.HibernateUtil.(Unknown Source)
[java] at hello.HelloWorld.main(Unknown Source)
[java] Caused by: org.hibernate.HibernateException: Could not parse configu ration: /hibernate.cfg.xml
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.jav a:2013)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java: 1925)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java: 1904)
[java] ... 2 more
[java] Caused by: org.dom4j.DocumentException: http://hibernate.org/hiberna te-configuration-3.0.dtd Nested exception: http://hibernate.org/hibernate-config uration-3.0.dtd
[java] at org.dom4j.io.SAXReader.read(SAXReader.java:484)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.jav a:2005)
[java] ... 4 more
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 2 seconds

Please let me know how to fix this.

1

1 Answers

0
votes

According to your exception may be there is configuration problem. First you use netbeans and then create java application with hibernate framework. Then may be true generated config file by netbeans usefull to solve out your problem.