This is very humbling….
I am new to Hibernate and am trying to get the example in chapter II working. I think that I have a simple problem but I can not get past it.. I have read through the FAQ and of course the manual but still no luck.. I am not using ANT instead using Eclipse for everything.
Here is my Event.hbm.xml and hibernate.cfg.xml files. But I think that they are fine.
<?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="Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="increment"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>
</hibernate-mapping>
================
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:data/tutorial</property>
<property name="connection.username">sa</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.HSQLDialect</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 resource="Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I think that hibernate uses some other mechanism to find and load the Event class. I just do not know how to set this up. Sorry I am just stuck.. Surly someone out there knows the answer to this simple question..
Thanks for you help
ray
Stack Trace:
09:14:32,626 INFO Environment:464 - Hibernate 3.0.5
09:14:32,626 INFO Environment:477 - hibernate.properties not found
09:14:32,626 INFO Environment:510 - using CGLIB reflection optimizer
09:14:32,642 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
09:14:32,705 INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
09:14:32,705 INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml
09:14:32,986 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
09:14:32,986 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
09:14:33,033 DEBUG Configuration:1067 - connection.driver_class=org.hsqldb.jdbcDriver
09:14:33,033 DEBUG Configuration:1067 - connection.url=jdbc:hsqldb:data/tutorial
09:14:33,033 DEBUG Configuration:1067 - connection.username=sa
09:14:33,033 DEBUG Configuration:1067 - connection.password=
09:14:33,033 DEBUG Configuration:1067 - connection.pool_size=1
09:14:33,033 DEBUG Configuration:1067 - dialect=org.hibernate.dialect.HSQLDialect
09:14:33,033 DEBUG Configuration:1067 - show_sql=true
09:14:33,033 DEBUG Configuration:1067 - hbm2ddl.auto=create
09:14:33,033 DEBUG Configuration:1262 - null<-org.dom4j.tree.DefaultAttribute@a97b0b [Attribute: name resource value "Event.hbm.xml"]
09:14:33,033 INFO Configuration:444 - Mapping resource: Event.hbm.xml
09:14:33,048 DEBUG DTDEntityResolver:42 - trying to locate
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
09:14:33,048 DEBUG DTDEntityResolver:53 - found
http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
09:14:33,173 INFO HbmBinder:260 - Mapping class: Event -> EVENTS
09:14:33,204 ERROR Configuration:365 - Could not compile the mapping document
org.hibernate.MappingException: class Event not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:81)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:275)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:360)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:294)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:236)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at src.HibernateUtil.<clinit>(HibernateUtil.java:10)
at src.EventManager.createAndStoreEvent(EventManager.java:19)
at src.EventManager.main(EventManager.java:12)
Caused by: java.lang.ClassNotFoundException: Event
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77)
... 17 more
Initial SessionFactory creation failed.org.hibernate.MappingException: Error reading resource: Event.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at src.HibernateUtil.<clinit>(HibernateUtil.java:14)
at src.EventManager.createAndStoreEvent(EventManager.java:19)
at src.EventManager.main(EventManager.java:12)
Caused by: org.hibernate.MappingException: Error reading resource: Event.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
at src.HibernateUtil.<clinit>(HibernateUtil.java:10)
... 2 more
Caused by: org.hibernate.MappingException: class Event not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:81)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:275)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:360)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:294)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:236)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
at org.hibernate.cfg.Configuration.add(Configuration.java:362)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 9 more
Caused by: java.lang.ClassNotFoundException: Event
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77)
... 17 more