-->
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.  [ 11 posts ] 
Author Message
 Post subject: hibernate.cfg.xml is not procesed?
PostPosted: Wed Feb 08, 2006 1:39 pm 
Newbie

Joined: Wed Feb 08, 2006 1:11 pm
Posts: 9
Hello everybody,

I am new to hibernate... I read the documentation but I cannot solve my problem. I wanted to test a little application. Here are the steps I followed:
1. I use Eclipse 3.1.1 together with hibernate Eclipse 3.1.0 beta 2 plugin
Hibernate version is 3.1
2. Database MYSQL with mysql 3.1.12 connection

3. The structure of the project is as follows:
02/08/2006 05:54 PM 810 hibernate.cfg.xml
02/08/2006 06:17 PM 1,631 InsertProduct.class
02/08/2006 06:17 PM 705 InsertProduct.java
02/08/2006 05:01 PM 1,095 Product.class
02/08/2006 05:37 PM 823 Product.hbm.xml
02/08/2006 04:49 PM 752 Product.java

The content of hibernate.cfg.xml is correct and it is the following:
<?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>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</property>
<property name="hibernate.connection.username">eduard</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>


However runnig the application I get the following error (you can see the log)
18:34:44,123 INFO Environment:474 - Hibernate 3.1 rc3
18:34:44,133 INFO Environment:504 - hibernate.properties not found
18:34:44,133 INFO Environment:520 - using CGLIB reflection optimizer
18:34:44,133 INFO Environment:550 - using JDK 1.4 java.sql.Timestamp handling
18:34:44,233 INFO Configuration:495 - Reading mappings from resource: product/Product.hbm.xml
18:34:44,734 INFO HbmBinder:265 - Mapping class: product.Product -> products
18:34:44,764 INFO Configuration:1021 - processing extends queue
18:34:44,764 INFO Configuration:1025 - processing collection mappings
18:34:44,764 INFO Configuration:1034 - processing association property references
18:34:44,764 INFO Configuration:1056 - processing foreign key constraints
18:34:44,854 WARN UserSuppliedConnectionProvider:23 - No connection properties specified - the user must supply JDBC connections
Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:378)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1830)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1150)
at product.InsertProduct.main(InsertProduct.java:17)

It seems to me that hibernate.cfg.xml is not procesed. I would be glad if someone can help me!

Regards!
Eduard


Top
 Profile  
 
 Post subject: Re: hibernate.cfg.xml is not procesed?
PostPosted: Wed Feb 08, 2006 1:46 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Eduard Barbu wrote:
Hello everybody,

I am new to hibernate... I read the documentation but I cannot solve my problem. I wanted to test a little application. Here are the steps I followed:
1. I use Eclipse 3.1.1 together with hibernate Eclipse 3.1.0 beta 2 plugin
Hibernate version is 3.1
2. Database MYSQL with mysql 3.1.12 connection

3. The structure of the project is as follows:
02/08/2006 05:54 PM 810 hibernate.cfg.xml
02/08/2006 06:17 PM 1,631 InsertProduct.class
02/08/2006 06:17 PM 705 InsertProduct.java
02/08/2006 05:01 PM 1,095 Product.class
02/08/2006 05:37 PM 823 Product.hbm.xml
02/08/2006 04:49 PM 752 Product.java

The content of hibernate.cfg.xml is correct and it is the following:
<?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>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</property>
<property name="hibernate.connection.username">eduard</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>


However runnig the application I get the following error (you can see the log)
18:34:44,123 INFO Environment:474 - Hibernate 3.1 rc3
18:34:44,133 INFO Environment:504 - hibernate.properties not found
18:34:44,133 INFO Environment:520 - using CGLIB reflection optimizer
18:34:44,133 INFO Environment:550 - using JDK 1.4 java.sql.Timestamp handling
18:34:44,233 INFO Configuration:495 - Reading mappings from resource: product/Product.hbm.xml
18:34:44,734 INFO HbmBinder:265 - Mapping class: product.Product -> products
18:34:44,764 INFO Configuration:1021 - processing extends queue
18:34:44,764 INFO Configuration:1025 - processing collection mappings
18:34:44,764 INFO Configuration:1034 - processing association property references
18:34:44,764 INFO Configuration:1056 - processing foreign key constraints
18:34:44,854 WARN UserSuppliedConnectionProvider:23 - No connection properties specified - the user must supply JDBC connections
Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:378)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1830)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1150)
at product.InsertProduct.main(InsertProduct.java:17)

It seems to me that hibernate.cfg.xml is not procesed. I would be glad if someone can help me!

Regards!
Eduard


http://www.hibernate.org/ForumMailingli ... AskForHelp

The usual issue is the file isn't found in the classpath. Are all the files listed above in the same directory ?

What does your code look like ?

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:20 pm 
Newbie

Joined: Wed Feb 08, 2006 1:11 pm
Posts: 9
Well, because I am working in Eclipse and I am lunching the program from Eclipse the file should be on the ClassPath. Moreover I used Hibernate Eclipse Plug-in for building configuration and mapping files.
the Structure of the Project is as follows:
HibernateRevista
+product (package)
hibernate.cfg.xml
InsertProduct.class
InsertProduct.java
Product.class
Product.hbm.xml
Product.java
hibernate.cfg.xml
log4j.properties

You can see that I copied for saftey hibernate.cfg.xml in the upper directory.
The class product is:
public class Product
private String id;
private String name;
private double price;
private int amount;
bla bla ...setters and getters


Product.hbm.xml is as follows:
<?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="product.Product" table="products">
<id name="id" type="string" unsaved-value="null">
<column name="id" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="name">
<column name="name" sql-type="char(255)" not-null="true"/>
</property>
<property name="price">
<column name="price" sql-type="double" not-null="true"/>
</property>
<property name="amount">
<column name="amount" sql-type="integer" not-null="true"/>
</property>
</class>
</hibernate-mapping>

and
public class InsertProduct {
public static void main(String[] args) throws Exception {
Product p = new Product();
p.setName(args[0]);
p.setAmount(Integer.parseInt(args[1]));
p.setPrice(Double.parseDouble(args[2]));

Configuration cfg = new Configuration().addClass(Product.class);
SessionFactory sf = cfg.buildSessionFactory();

Session sess = sf.openSession();

Transaction t = sess.beginTransaction();
sess.save(p);
t.commit();
sess.close();
}
}
is here. The database and the table are created and are visible from Hibernate Console view. So I can't see were is the problem.

Best Regards!
Eduard


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:39 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
You're never calling the configure() method.

new Configuration().configure().buildSessionFactory()

Or in your case

Configuration cfg = new Configuration().addClass(Product.class);
SessionFactory sf = cfg.configure().buildSessionFactory();

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:01 pm 
Newbie

Joined: Wed Feb 08, 2006 1:11 pm
Posts: 9
I replaced the file hibernate.cfg.xml with hibernate.properties. Now hibernate.properties is processed. However the following error occurs:
:59,778 INFO Environment:474 - Hibernate 3.1 rc3
19:27:59,788 INFO Environment:489 - loaded properties from resource hibernate.properties: {hibernate.connection.username=eduard, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/hibernate, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver}
19:27:59,788 INFO Environment:520 - using CGLIB reflection optimizer
19:27:59,788 INFO Environment:550 - using JDK 1.4 java.sql.Timestamp handling
19:27:59,888 INFO Configuration:495 - Reading mappings from resource: product/Product.hbm.xml
19:28:00,409 INFO HbmBinder:265 - Mapping class: product.Product -> products
19:28:00,439 INFO Configuration:1021 - processing extends queue
19:28:00,439 INFO Configuration:1025 - processing collection mappings
19:28:00,439 INFO Configuration:1034 - processing association property references
19:28:00,439 INFO Configuration:1056 - processing foreign key constraints
19:28:00,549 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
19:28:00,549 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
19:28:00,549 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:57)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1830)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1150)
at product.InsertProduct.main(InsertProduct.java:17)
Does anyone know from were it is this error?

Regards!
Eduard


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:06 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
This isn't a Hibernate issue...

http://forum.java.sun.com/thread.jspa?t ... ID=3584032

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:09 pm 
Newbie

Joined: Wed Feb 08, 2006 1:11 pm
Posts: 9
Dear Preston,

I did not see your post so I post again (YM put the mail that notice me in the Bulk folder :)).

I am now trying your solution.

Best Regards and thanks!
Eduard


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:10 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Eduard Barbu wrote:
Dear Preston,

I did not see your post so I post again (YM put the mail that notice me in the Bulk folder :)).

I am now trying your solution.

Best Regards and thanks!
Eduard


ok. But you might still get the NoClassDefFoundError issue since that apparently has to do with the MySQL driver classes.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:34 pm 
Newbie

Joined: Wed Feb 08, 2006 1:11 pm
Posts: 9
It does not work and crashes with the message:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
as above (when I used hibernate.properties obviously)
Could be this a database connector problem?

Regards!
Eduard


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:37 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Eduard Barbu wrote:
It does not work and crashes with the message:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
as above (when I used hibernate.properties obviously)
Could be this a database connector problem?

Regards!
Eduard


You seem to be missing my responses.... read the last two over.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 3:49 pm 
Newbie

Joined: Wed Feb 08, 2006 1:11 pm
Posts: 9
Ok thanks ...I gave you credit. This is the problem, I am trying to replace the database connector! I will see tommorow if it works.

Regards!
Eduard


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