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.  [ 4 posts ] 
Author Message
 Post subject: Can't get Hibernate Example to work
PostPosted: Wed Jul 20, 2005 11:28 am 
Newbie

Joined: Wed Jul 20, 2005 10:48 am
Posts: 2
I followed the Introduction to Hibernate (Chapter 2), I insured that all my code and xml files were copied correctly. When I compile the project I get

Code:
C:\Documents and Settings\Administrator\Desktop\Events>ant
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\Documents and Settings\Administrator\Desktop\E
vents\bin
    [mkdir] Created dir: C:\Documents and Settings\Administrator\Desktop\Events\bin

copy-resources:
     [copy] Copying 2 files to C:\Documents and Settings\Administrator\Desktop\E
vents\bin

compile:
    [javac] Compiling 3 source files to C:\Documents and Settings\Administrator\
Desktop\Events\bin
    [javac] Note: C:\Documents and Settings\Administrator\Desktop\Events\src\Hib
ernateUtil.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.


Not sure what unchecked or unsafe operation are?????? But the real problem is when I try to run the actual program....I get the following...

Code:

C:\Documents and Settings\Administrator\Desktop\Events>ant run -Daction=store
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\Documents and Settings\Administrator\Desktop\E
vents\bin
    [mkdir] Created dir: C:\Documents and Settings\Administrator\Desktop\Events\
bin

copy-resources:
     [copy] Copying 2 files to C:\Documents and Settings\Administrator\Desktop\E
vents\bin

compile:
    [javac] Compiling 3 source files to C:\Documents and Settings\Administrator\
Desktop\Events\bin
    [javac] Note: C:\Documents and Settings\Administrator\Desktop\Events\src\Hib
ernateUtil.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.

run:
     [java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg
.Environment).
     [java] log4j:WARN Please initialize the log4j system properly.
     [java] Initial SessionFactory creation failed.org.hibernate.HibernateExcept
ion: problem parsing configuration/hibernate.cfg.xml
     [java] Exception in thread "main" java.lang.ExceptionInInitializerError
     [java]     at HibernateUtil.<clinit>(Unknown Source)
     [java]     at EventManager.createAndStoreEvent(Unknown Source)
     [java]     at EventManager.main(Unknown Source)
     [java] Caused by: org.hibernate.HibernateException: problem parsing configu
ration/hibernate.cfg.xml
     [java]     at org.hibernate.cfg.Configuration.doConfigure(Configuration.jav
a:1173)
     [java]     at org.hibernate.cfg.Configuration.configure(Configuration.java:
1112)
     [java]     at org.hibernate.cfg.Configuration.configure(Configuration.java:
1098)
     [java]     ... 3 more
     [java] Caused by: org.dom4j.DocumentException: Error on line 1 of document
: The ' = ' character must follow "version-" in the XML declaration. Nested exc
eption: The ' = ' character must follow "version-" in the XML declaration.
     [java]     at org.dom4j.io.SAXReader.read(SAXReader.java:482)
     [java]     at org.hibernate.cfg.Configuration.doConfigure(Configuration.jav
a:1168)
     [java]     ... 5 more
     [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 5 seconds
C:\Documents and Settings\Administrator\Desktop\Events>


Any help with this would be greatly appreciated. I figured that starting with the getting started guide on this site would be a great place to learn hibernate, but it won't work..... :( . Thanks for any help in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 11:48 am 
Beginner
Beginner

Joined: Mon Apr 12, 2004 6:33 pm
Posts: 35
Looks like an error in your mapping file. It should start with an xml declaration:
Code:
<?xml version="1.0" encoding="UTF-8"?>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 12:14 pm 
Newbie

Joined: Wed Jul 20, 2005 10:48 am
Posts: 2
Thanks a lot that helped...it ran correctly....I still get this on compile

Code:
compile:
    [javac] Compiling 3 source files to C:\Documents and Settings\Administrator\
Desktop\Events\bin
    [javac] Note: C:\Documents and Settings\Administrator\Desktop\Events\src\Hib
ernateUtil.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.


And this on run

Code:
[java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg
.Environment).
     [java] log4j:WARN Please initialize the log4j system properly.


Not quite sure what they mean. I know they are only warnings, but I would like to get rid of them. Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 3:57 pm 
Beginner
Beginner

Joined: Mon Apr 12, 2004 6:33 pm
Posts: 35
The first warning presents you with its solution: add the -Xlint compiler directive.

The second warning can be solved by placing the log4j.properties file on the classpath.


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