Hibernate version:
version 3.1
Full stack trace of any exception that occurs:
Code:
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.postgresql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=pg, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:postgresql:template1, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: using java.io streams to persist binary types
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 29, 2006 2:49:10 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Initial SessionFactory creation failed. org.hibernate.HibernateException: /hibernate.cfg.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError
at src.util.HibernateUtil.<clinit>(HibernateUtil.java:20)
at src.events.EventManager.createAndStoreEvent(EventManager.java:22)
at src.events.EventManager.main(EventManager.java:14)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1265)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1287)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
at src.util.HibernateUtil.<clinit>(HibernateUtil.java:14)
... 2 more
Name and version of the database you are using:PostgreSQL 8.0
I am trying to get hibernate running from the tutorial example found here:
http://www.hibernate.org/hib_docs/v3/re ... orial.htmlI am having a few problems with this, specifically, here:
http://www.hibernate.org/hib_docs/v3/re ... ersistenceMore precisely:
Quote:
The value of the action argument is set on the command line when calling the target:
C:\hibernateTutorial\>ant run -Daction=store
You should see, after compilation, Hibernate starting up and, depending on your configuration, lots of log output. At the end you will find the following line:
[java] Hibernate: insert into EVENTS (EVENT_DATE, title, EVENT_ID) values (?, ?, ?)
When I use ant, I receive this:
Quote:
C:\James' Stuff\Programs\eclipse\workspace\DB>ant run -Daction=store
Buildfile: build.xml
clean:
[delete] Deleting directory C:\James' Stuff\Programs\eclipse\workspace\DB\bin
[mkdir] Created dir: C:\James' Stuff\Programs\eclipse\workspace\DB\bin
copy-resources:
[copy] Copying 6 files to C:\James' Stuff\Programs\eclipse\workspace\DB\bin
compile:
run:
[java] java.lang.NoClassDefFoundError: src/events/EventManager
[java] Exception in thread "main"
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 1 second
When I use eclipse I receive the stack trace printed above.
This is how my directories are set up and what is in them:
Code:
+lib
antlr.jar
cglib.jar
asm.jar
asm-attrs.jars
commons-collections.jar
commons-logging.jar
hibernate3.jar
jta.jar
dom4j.jar
postgresql-8.0-311.jdbc3.jar
+src
hibernate.cfg.xml
log4j.properties
+events
Event.java
Event.class
Event.hbm.xml
EventManager.java
EventManager.class
+util
HibernateUtil.java
HibernateUtil.class
+data
+bin
copies of the src directory (this is made when ant is ran)
build.xml
hibernate.properties
I am not knowledgable in databases so I am not entirely sure what is causing this problem. I know my database is working. I have used navicat to go in and modify the contents of it. While in pgadmin 3, I make sure it is connected.
When I run ant and eclipse, I get 2 different error messages.
with ant: it cannot seem to create a class that doesn't exist (makes sense, but it doesn't give me enough information to try and fix this).
with eclipse: it cannot find the hibernate.cfg.xml. HOWEVER, in the previous messages as it runs indicates that it did find it!:
Quote:
Jan 29, 2006 2:59:47 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 29, 2006 2:59:47 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Initial SessionFactory creation failed. org.hibernate.HibernateException: /hibernate.cfg.xml not found
I have went over the tutorial several times and went to FAQ with the common problems but I haven't seen anyting that resembles mine. Finally, I have talked to one of my friends who has used hibernate somewhat before and even had him send me a working eclipse project that has used it. From that I thought I could find the differences, but he appears to have LESS hibernate files/stuff in his project then I do. I hope I have provided enough information to receive some assistance.
Thank you for your time.
EDIT:
My hibernate config file:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-configuration (View Source for full doctype...)>
- <hibernate-configuration>
- <session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/riesuts</property>
<property name="hibernate.connection.password">dbtest</property>
<property name="hibernate.connection.username">hibernate</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="src/events/Event.hbm.xml" />
</session-factory>
</hibernate-configuration>