-->
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.  [ 6 posts ] 
Author Message
 Post subject: hibernate.cfg.xml don't found. I'm wonder
PostPosted: Mon Oct 16, 2006 2:28 pm 
Regular
Regular

Joined: Mon Oct 02, 2006 12:03 pm
Posts: 62
Image

Hello I'm using Hibernate Synchronizer and I have this structure project. When I execute Prova.java class as Main process hibernate dumps me this:

Can you say me what happens. I'm wondering

Thanks in advance

Main process -->

Code:
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      com.gmsoft.model.Rols rol = new com.gmsoft.model.Rols((byte)60);
      rol.setDescripcio("Hibernate");
      
      com.gmsoft.model.dao.RolsDAO rolDAO = new com.gmsoft.model.dao.RolsDAO();
      System.out.println("intentant guardar un rol...");
      rolDAO.save(rol,rolDAO.getSession());
      System.out.println("rol guardat!!!");
   }



intentant guardar un rol...
Code:
16-oct-2006 20:19:14 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1.3
16-oct-2006 20:19:15 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
16-oct-2006 20:19:15 org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
16-oct-2006 20:19:15 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
16-oct-2006 20:19:15 org.hibernate.cfg.Configuration configure
INFO: configuring from resource:
16-oct-2006 20:19:15 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource:
16-oct-2006 20:19:15 org.hibernate.util.XMLHelper$ErrorLogger error
GRAVE: Error parsing XML: (1) Content is not allowed in prolog.
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration:
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1376)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
   at com.gmsoft.model.base._BaseRootDAO.initialize(_BaseRootDAO.java:104)
   at com.gmsoft.model.base._BaseRootDAO.initialize(_BaseRootDAO.java:88)
   at com.gmsoft.model.base._BaseRootDAO.getSessionFactory(_BaseRootDAO.java:145)
   at com.gmsoft.model.base._BaseRootDAO.getSession(_BaseRootDAO.java:64)
   at com.gmsoft.model.base._BaseRootDAO.getSession(_BaseRootDAO.java:42)
   at com.gmsoft.Prova.main(Prova.java:15)
Caused by: org.dom4j.DocumentException: Error on line 1 of document  : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
   at org.dom4j.io.SAXReader.read(SAXReader.java:482)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1366)
   ... 7 more


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 2:40 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
It looks like the file is properly found but it is 'corrupt' in one way or another. Look at the xml file and see if you can figure it out, otherwise post as text only.

Marius


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 2:58 am 
Regular
Regular

Joined: Mon Oct 02, 2006 12:03 pm
Posts: 62
hibernate.cfg.xml -->

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory name="GeneralFactory">
      <!-- local connection properties -->
      <property name="hibernate.connection.url">
         jdbc:sqlserver://SERVER2003;databaseName=KoetDB
      </property>
      <property name="hibernate.connection.driver_class">
         com.microsoft.sqlserver.jdbc.SQLServerDriver
      </property>
      <property name="hibernate.connection.username">CABRE2</property>
      <property name="hibernate.connection.password">CABRE2</property>
      <!-- property name="hibernate.connection.pool_size"></property -->
      <!-- dialect for Microsoft SQL Server -->
      <property name="dialect">
         org.hibernate.dialect.SQLServerDialect
      </property>
      <property name="hibernate.show_sql">false</property>
      <property name="hibernate.transaction.factory_class">
         org.hibernate.transaction.JDBCTransactionFactory
      </property>
      <mapping resource="Rols.hbm.xml" />
   </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 3:53 am 
Regular
Regular

Joined: Mon Oct 02, 2006 12:03 pm
Posts: 62
One thing, I've changed the name of hibernate.cfg.xml to hibernadddddfdfte.cfg.xml and the message is the same. So, I continue thinking that this file isn't found.

Any idea more?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 9:43 am 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Hi,

I looked again at your code and exception. Is that ALL that you have in Main? Most people in this forum use hibernate in a web application and initialize it with a servlet/listener. For a standalone program you need to do all of that yourself. You need to initialize the Hibernate configuration, the session factory then get a session before you can run any of the DAO code. You need to do something like....

Code:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

....
      Configuration configuration = new Configuration().configure();
      sessionFactory = configuration.buildSessionFactory();
                session = sessionFactory.openSession();


Let me know if this helps...

Marius


Top
 Profile  
 
 Post subject: Re: hibernate.cfg.xml don't found. I'm wonder
PostPosted: Wed Nov 08, 2006 9:00 am 
Newbie

Joined: Thu Sep 23, 2004 11:53 am
Posts: 8
Location: Maracaibo, Venezuela
Hi jeusdi, besides the comments of mseritan , since it seems you are using Windows by your screenshot make sure you edit the hibernate.cfg.xml with the proper editor, what I mean I had similar issues whenever I edited with Notepad and not with Wordpad (for example) due to how this windows applications handle the CR and FF characters differently and introduce errors in the xml file making impossible por the XML parser used by Hibernate read it correctly, another way to edit the file could be using the editor provided by Eclipse which is already configured properly to handle the platforms differences for the CR and FF.

Hope this helps,
Pedro Taborda

_________________
Pedro Taborda
Procedatos,S.A.
Phone: (58414)6124848


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