-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate- ant errors
PostPosted: Mon Jan 28, 2008 2:15 am 
Newbie

Joined: Mon Jan 28, 2008 1:55 am
Posts: 8
Hi im totaly new for Hibernate
im using hibernate_3.0.3 and mysql as the database

im working my way trough the the hibernate tutorial
http://www.hibernate.org/hib_docs/refer ... orial.html

but when i did
C:\hibernateTutorial\>ant run -Daction=store

i got following errors


Buildfile: build.xml

clean:
[delete] Deleting directory /home/wijitha/programing/hibernate/Event_ex/bin
[mkdir] Created dir: /home/wijitha/programing/hibernate/Event_ex/bin

copy-resources:
[copy] Copying 3 files to /home/wijitha/programing/hibernate/Event_ex/bin
[copy] Copied 2 empty directories to 1 empty directory under /home/wijitha/programing/hibernate/Event_ex/bin

compile:
[javac] Compiling 3 source files to /home/wijitha/programing/hibernate/Event_ex/bin

run:
[java] 11:08:54,422 INFO Environment:464 - Hibernate 3.0.3
[java] 11:08:54,430 INFO Environment:477 - hibernate.properties not found
[java] 11:08:54,434 INFO Environment:510 - using CGLIB reflection optimizer
[java] 11:08:54,438 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
[java] 11:08:54,579 INFO Configuration:1160 - configuring from resource: /hibernate.cfg.xml
[java] 11:08:54,580 INFO Configuration:1131 - Configuration resource: /hibernate.cfg.xml
[java] 11:08:54,797 INFO Configuration:441 - Mapping resource: events/Event.hbm.xml
[java] 11:08:54,819 ERROR XMLHelper:59 - Error parsing XML: XML InputStream(1) Document is invalid: no grammar found.
[java] 11:08:54,821 ERROR XMLHelper:59 - Error parsing XML: XML InputStream(1) Document root element "hibernate-mapping", must match DOCTYPE root "null".
[java] Initial SessionFactory creation failed.org.hibernate.MappingException: Error reading resource: events/Event.hbm.xml
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at util.HibernateUtil.<clinit>(Unknown Source)
[java] at events.EventManager.createAndStoreEvent(Unknown Source)
[java] at events.EventManager.main(Unknown Source)
[java] Caused by: org.hibernate.MappingException: Error reading resource: events/Event.hbm.xml
[java] at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
[java] at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1313)
[java] at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1285)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1267)
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1234)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1162)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1148)
[java] ... 3 more
[java] Caused by: org.hibernate.MappingException: invalid mapping
[java] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:396)
[java] at org.hibernate.cfg.Configuration.addResource(Configuration.java:446)
[java] ... 9 more
[java] Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
[java] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
[java] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
[java] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
[java] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
[java] at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:250)
[java] at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3084)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:912)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:645)
[java] at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
[java] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:508)
[java] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
[java] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
[java] at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
[java] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
[java] at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
[java] at org.dom4j.io.SAXReader.read(SAXReader.java:465)
[java] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:395)
[java] ... 10 more
[java] Java Result: 1

BUILD SUCCESSFUL

all the xml files and java files are same as which are in the tutorial.


and the other thing is,
in my EventManager.java
session.getTransaction().commit(); is giving an error (there is no commit() withing
session.getTransaction())

package events;
import org.hibernate.Session;

import java.util.Date;

import util.HibernateUtil;

public class EventManager {

public static void main(String[] args) {
EventManager mgr = new EventManager();

// if (args[0].equals("store")) {
mgr.createAndStoreEvent("My Event", new Date());
// }

HibernateUtil.getSessionFactory().close();
}

private void createAndStoreEvent(String title, Date theDate) {

Session session = HibernateUtil.getSessionFactory().getCurrentSession();

session.beginTransaction();

Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);

session.save(theEvent);

session.getTransaction().commit(); //********************
}

}
if any one can help me please reply me. thanks.

regards
wijitha


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 2:25 am 
Regular
Regular

Joined: Mon Aug 20, 2007 6:47 am
Posts: 74
Location: UK
Can you check that your Event.hbm.xml file looks the same as this?

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

    <class name="events.Event" table="EVENTS">
        <id name="id" column="EVENT_ID">
            <generator class="native"/>
        </id>
        <property name="date" type="timestamp" column="EVENT_DATE"/>
        <property name="title"/>
    </class>

</hibernate-mapping>


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