hello all ,am trying to save some data in person table through hibernate my main class is as follows: package com.myapp.struts; import org.hibernate.*; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import java.util.Date;
/** * * @author shabarish */ public class *Main *{ public static void main(String[] args) { SessionFactory sessions = new Configuration().configure().buildSessionFactory(); Session session = sessions.openSession(); Transaction tx = null; try { tx = session.beginTransaction(); Person person = new Person(); person.setPersonid(1); person.setName("shabarish"); person.setJobtitle("SE"); person.setFrequentflyer("Yes"); person.setLastupdated(new Date()); session.save(person); tx.commit(); tx = null; }catch ( HibernateException e ) { if ( tx != null ) tx.rollback(); e.printStackTrace(); } finally { session.close(); } } } all my hibernate cgf file and hbm file and Main class file are in * com.myapp.struts*;. package. when i try to run Main class i get the following error: init: deps-module-jar: deps-ear-jar: deps-jar: Copying 1 file to D:\NetBeansProjects\firstHibernate\build\web\WEB-INF\classes compile-single: run-main: Jun 17, 2009 8:49:26 PM org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.2.5 Jun 17, 2009 8:49:26 PM org.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found Jun 17, 2009 8:49:26 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: Bytecode provider name : cglib Jun 17, 2009 8:49:26 PM org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling Jun 17, 2009 8:49:26 PM org.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml Jun 17, 2009 8:49:26 PM org.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml Jun 17, 2009 8:49:26 PM org.hibernate.util.XMLHelper$ErrorLogger error SEVERE: Error parsing XML: /hibernate.cfg.xml(1) Content is not allowed in prolog. Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494) at org.hibernate.cfg.Configuration.configure(Configuration.java:1428) at org.hibernate.cfg.Configuration.configure(Configuration.java:1414) at com.myapp.struts.Main.main(Main.java:18) 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:1484) ... 3 more Java Result: 1 BUILD SUCCESSFUL (total time: 4 seconds) PLEASE HELP ME IN THIS. my *hibernate.cfg.xml* is : <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/TRAVEL</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <mapping resource="com/myapp/struts/Person.hbm.xml"/> </session-factory> </hibernate-configuration> please help me. -- Thanks, Shabarish.V --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en -~----------~----~----~----~------~----~------~--~---