wood burning stoves
The moose likes Object Relational Mapping and the fly likes problem parsing hibernate.cfg.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "problem parsing hibernate.cfg.xml" Watch "problem parsing hibernate.cfg.xml" New topic

problem parsing hibernate.cfg.xml

sai vangari

Joined: Apr 14, 2012
Posts: 5
Oct 01, 2012 10:39:18 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Oct 01, 2012 10:39:18 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.7.Final}
Oct 01, 2012 10:39:18 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Oct 01, 2012 10:39:18 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Oct 01, 2012 10:39:18 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Oct 01, 2012 10:39:18 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2023)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
at org.sai.hibernate.HibernateTest.main(HibernateTest.java:20)
Caused by: org.dom4j.DocumentException: Error on line 3 of document : The document type declaration for root element type "hibernate-configuration" must end with '>'. Nested exception: The document type declaration for root element type "hibernate-configuration" must end with '>'.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2015)
... 3 more

my cfg.xml file is

<?xml version='1.0' encoding='utf-8'?>
<!-- ~ Hibernate, Relational Persistence for Idiomatic Java ~ ~ Copyright (c) 2010, Red Hat Inc. or third-party contributors as ~ indicated by the @author tags or express copyright attribution ~ statements applied by the authors. All third-party contributions are ~ distributed under license by Red Hat Inc. ~ ~ This copyrighted material is made available to anyone wishing to use, modify, ~ copy, or redistribute it subject to the terms and conditions of the GNU ~ Lesser General Public License, as published by the Free Software Foundation. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ~ for more details. ~ ~ You should have received a copy of the GNU Lesser General Public License ~ along with this distribution; if not, write to: ~ Free Software Foundation, Inc. ~ 51 Franklin Street, Fifth Floor ~ Boston, MA 02110-1301 USA -->
<!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN">
-<hibernate-configuration> -<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbcracle:thin:@//localhost:1521/XE</property>
<property name="connection.username">username</property>
<property name="connection.password">***</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping class="org.sai.dto.UserDetails"/>
</session-factory> </hibernate-configuration>
Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 191
Where did you copy the hibernate.cfg.xml from to insert it into your posting?

This could be wrong. But i'm not sure that you didn't copy the file out of a browser that uses folding for xml-files...
sai vangari

Joined: Apr 14, 2012
Posts: 5
yes i did copied the xml file that i found in hibernate project folder and altered it .
thanks for your concern but i did solved my problem later realizing my mistake..

i want you to help me out in another problem which i couldn't understand why it is happening..i'm a newbie to hibernate so please do help me out in this...

after inserting the values into the database...i found that the fields are arranged in vertical order but not in horizontal way,something like this..

SQL> select * from userdetails
2 ;








can you explain how to get rid out of this weird look..
Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 191
That's not a problem of hibernate or your application, that's a problem of your SQL-client. If you are using Oracle that's SQLPlus. It has a command "set linesize" to - well quite obvious - set the linesize. E.g. "set linesize 200" to have a linesize of 200. If you are running SQLPLus via cmd.exe make sure that the window buffer of the cmd-window is set same. SQLplus runs into that "problem" because your field username or userid are defined e.g. as VARCHAR2(150) and SQLplus "reserves" that size in the output and ignores the real size of the values. (It cannot do something like "trim" because when starting to spool the maximum length of all the entries inside the table isn't know...)
sai vangari

Joined: Apr 14, 2012
Posts: 5
Thanks a lot dillinger
your priceless reply means a lot to me...
you are helping me out in learning new things.

also, when i try to run the code,
a new unknown table is being created...its happening whenever i create a new table..i'l copy paste the output below..

SQL*Plus: Release - Production on Tue Oct 2 14:22:11 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.

SQL> connect
Enter user-name: sai
Enter password:
SQL> select * from tab;

------------------------------ ------- ----------
BIN$2eHUhYiQRM+Fi2cyZwmC9Q==$0 TABLE
BIN$6dMvFP/dRgulUNYyzE29mw==$0 TABLE

7 rows selected.

can you explain how to solve this issue too?
Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 191
That's Oracle's recycle bin. Try Google with "purge oracle recycle bin" as I don't know the correct syntax. (Usually our DBA cleans up from time to time...)
sai vangari

Joined: Apr 14, 2012
Posts: 5
thank you sir ...
all my doubts are cleared now...
to drop those tables, the syntax we need to use is "purge recyclebin" .
thanks again for posting replies to me.
I agree. Here's the link: http://aspose.com/file-tools
subject: problem parsing hibernate.cfg.xml
jQuery in Action, 3rd edition