-->
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.  [ 7 posts ] 
Author Message
 Post subject: hibernate.connection.driver_class error
PostPosted: Thu May 08, 2008 12:27 pm 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
We're switching over to use ConfigurationSectionHandler (switching from NameValueSectionHandler) in our App.config and BuildSessionFactory returns an error, "The hibernate.connection.driver_class must be specified in the NHibernate configuration section.", despite the fact that we have this. Note also that in our old way when using NameValueSectionHandler, we didn't have to specify hibernate.connection.driver_class. Any ideas on what we're doing wrong?

Here's the simple code snippet:
NHibernate.Cfg.Configuration cfg = new NHibernateConfiguration();
ISessionFactory sf = cfg.BuildSessionFactory();



Pertinent parts of App.config:
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="hibernate.connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="hibernate.connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="hibernate.connection.connection_string">Server=localhost;initial catalog=CHNOPSDb;Integrated Security=SSPI</property>
<property name="hibernate.bytecode.provider">null</property>
<property name="hibernate.current_session_context_class">managed_web</property>
<property name="hibernate.max_fetch_depth">4</property>
</session-factory>
</hibernate-configuration>


NOTE: The following worked but I'm trying to get the above to work now --

<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>

<nhibernate>
<add key="hibernate.show_sql" value="true"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect"/>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.connection.connection_string" value="Server=localhost;initial catalog=CHNOPSDb;Integrated Security=SSPI"/>
<add key="hibernate.bytecode.provider" value="null"/>
<add key="hibernate.current_session_context_class" value="managed_web"/>
<add key="hibernate.max_fetch_depth" value="4"/>
</nhibernate>

_________________
metazone


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 09, 2008 3:27 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I'm not sure if that's the problem, but as I can remember, you don't need the hibernate prefix, when you use this configuration style:

Code:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="show_sql">true</property>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Server=localhost;initial catalog=CHNOPSDb;Integrated Security=SSPI</property>
<property name="hibernate.bytecode.provider">null</property>
<property name="current_session_context_class">managed_web</property>
<property name="hibernate.max_fetch_depth">4</property>
</session-factory>
</hibernate-configuration>

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 09, 2008 11:02 am 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
Thanks, Wolfgang -- I did try to remove the prefix and received the same error :( ...

_________________
metazone


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 8:11 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Is it possible that your App.config is flagged as "Embedded Resource" ? I just found out, that that isn't working. You have to set build action to "None".

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 10:38 am 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
Thanks again -- unfortunately, App.config is not embedded -- I appreciate the suggestions!

_________________
metazone


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 12:18 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You're using 1.2, right ? I was curious and digged through the docs again and found this in chapter 3.5 of the reference documentation:

Quote:
System-level properties can only be set manually by setting static properties of NHibernate.Cfg.Environment
class or be defined in the <nhibernate> section of the application configuration file. These properties cannot be
set using Configuration.SetProperties or be defined in the <hibernate-configuration> section of the application
configuration file.


Followed by a list of the relevant options, including dialect. According to this, I would say, your approach will not work :-(. I think the behaviour is different with 2.0, where this should be possible.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 2:27 pm 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
Thanks, again -- Yes, we're using a custom-built version that's not 2.0 (we needed a special fix). Thanks very much -- you solved it :)

_________________
metazone


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