-->
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.  [ 6 posts ] 
Author Message
 Post subject: Unhandled exception
PostPosted: Sat Feb 17, 2007 6:20 am 
Newbie

Joined: Sat Feb 17, 2007 6:03 am
Posts: 3
Hello!

I have a problem using nHibernate with Sql Server Express 2005 and Asp.NET

Everything works fine until runtinme, when the get the unhandled exception:

<session-factory> element was not found in the configuration file.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.MappingException: <session-factory> element was not found in the configuration file.

Source Error:


Code:
Line 12:       static NHibernateHelper()
Line 13:       {
Line 14:          sessionFactory = new Configuration().Configure().BuildSessionFactory();
Line 15:       }
Line 16:       public static ISession GetCurrentSession()



Source File: c:\Tiamp.Net\tests\QuickStart\App_Code\Cat.cs Line: 14

Stack Trace:


[MappingException: <session-factory> element was not found in the configuration file.]
NHibernate.Cfg.Configuration.DoConfigure(XmlDocument doc) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\Configuration.cs:1360
NHibernate.Cfg.Configuration.Configure(XmlTextReader reader) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\Configuration.cs:1347
NHibernate.Cfg.Configuration.Configure(XmlNode node) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\Configuration.cs:1237
NHibernate.Cfg.Configuration.Configure() in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\Configuration.cs:1218
QuickStart.NHibernateHelper..cctor() in c:\Tiamp.Net\tests\QuickStart\App_Code\Cat.cs:14

[TypeInitializationException: The type initializer for 'QuickStart.NHibernateHelper' threw an exception.]
QuickStart.NHibernateHelper.GetCurrentSession() in c:\Tiamp.Net\tests\QuickStart\App_Code\Cat.cs:26
_Default.Button1_Click(Object sender, EventArgs e) in c:\Tiamp.Net\tests\QuickStart\Default.aspx.cs:24
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838


I want to mention that i followed the exact steps described in the nReference manual(QuikStart example) that you can find here:http://www.hibernate.org/hib_docs/nhibernate/nhibernate_reference.pdf


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 17, 2007 8:00 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Did you put the <session-factory> in your app config?
What NH version?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 17, 2007 9:42 am 
Newbie

Joined: Sat Feb 17, 2007 6:03 am
Posts: 3
Ayende Rahien wrote:
Did you put the <session-factory> in your app config?
What NH version?

Hi,

I'm using NHibernate-1.2.0.Beta3-debug version and my web.config file looks like this:

Code:
<?xml version="1.0"?>
<configuration>
   <configSections>
      <sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
         <sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
               <section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
               <section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
               <section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
            </sectionGroup>
         </sectionGroup>
      </sectionGroup>
      <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
   </configSections>
   
   <hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">
      <session-factory>
         <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
         <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
         <property name="connection.connection_string">
            Server=(local);initial catalog=quickstart;Integrated <mapping assembly="QuickStart"/>
         </property>
      </session-factory>
   </hibernate-configuration>
   
   <system.web>
      <pages>
         <controls>
            <add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
         </controls>
         <tagMapping>
            <add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
         </tagMapping>
      </pages>
      <!--
          Set compilation debug="true" to insert debugging
          symbols into the compiled page. Because this
          affects performance, set this value to true only
          during development.
    -->
      <compilation debug="true">
         <assemblies>
            <add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
         </assemblies>
      </compilation>
      <httpHandlers>
         <remove verb="*" path="*.asmx"/>
         <add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
         <add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>
      </httpHandlers>
      <httpModules>
         <add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
         <add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </httpModules>
   </system.web>
   <microsoft.web>
      <scripting>
         <webServices>
            <!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
            <!--
      <jsonSerialization maxJsonLength="500">
        <converters>
          <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
        </converters>
      </jsonSerialization>
      -->
            <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
            <!--
        <authenticationService enabled="true" requireSSL = "true|false"/>
      -->
            <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
           and modified in Atlas applications, you need to add each property name to the setProperties and
           getProperties attributes. -->
            <!--
      <profileService enabled="true"
                      readAccessProperties="propertyname1,propertyname2"
                      writeAccessProperties="propertyname1,propertyname2" />
      -->
         </webServices>
      </scripting>
   </microsoft.web>
   <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <modules>
         <add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </modules>
      <handlers>
         <remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
         <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
         <add name="ScriptResource" verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler"/>
      </handlers>
   </system.webServer>
</configuration>


So yes,I added <session-factory> to my web.config file.
The problem is i'm not even sure if nHIbernate works with SQL Server Express 2005 and .NET 3.0beta. If someone managed this, it would be great to know how.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 17, 2007 10:16 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
In 1.2.0-Beta3 and above you should use xmlns="urn:nhibernate-configuration-2.2" (note the number at the end).


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 17, 2007 11:36 am 
Newbie

Joined: Sat Feb 17, 2007 6:03 am
Posts: 3
sergey wrote:
In 1.2.0-Beta3 and above you should use xmlns="urn:nhibernate-configuration-2.2" (note the number at the end).


I tried and no succes!I still get the same error...I think a person who susccesfully run the QuikStart example from the nHibernate reference, will be able to help me...

Thx


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 18, 2007 3:32 pm 
Newbie

Joined: Sat Feb 17, 2007 5:29 am
Posts: 2
Hi veryone !

I get the same error...
Has someone found a solution to that problem ?

Thanks for any idea...


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