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.  [ 4 posts ] 
Author Message
 Post subject: newbie web.config help "NHibernate.MappingException&quo
PostPosted: Wed Feb 28, 2007 10:12 am 
Newbie

Joined: Wed Feb 28, 2007 9:54 am
Posts: 2
hi,

i'm new to nhibernate and i have some problems setting up nhibernate.

first, that's what my folder-structure looks like:
Image

second, my Customer.hbm.xml file:
Code:
<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="Customer" table="Customer">
    <id name="id" column="id" type="int">
      <generator class="identity" />
    </id>
    <property name="name" type="string" column="name"></property>
    <property name="vorname" type="string" column="vorname"></property>
  </class>
</hibernate-mapping>


third, my Web.Config-File
Code:
<?xml version="1.0"?>
<configuration>
   <configSections>
      <sectionGroup name="spring">
         <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
      <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
      </sectionGroup>
    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.1.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  </configSections>
 
   <spring>
      <context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
              <resource uri="config://spring/objects" />
      </context>
      <objects xmlns="http://www.springframework.net">
         <object name="customerService" type="Service.CustomerService">
            <property name="customerDAO" ref="customerDAO"/>
         </object>
         <object name="customerDAO" type="Dao.CustomerDAO">
            <property name="SessionFactory" ref="sessionFactory"/>
         </object>

      <!--
         <object id="dbProvider" type="Spring.Data.Support.MySql, Spring.Data">
            <property name="ConnectionString" value="Data Source=localhost;Initial Catalog=test;User Id=root;Password=tutorials"/>
         </object>
      -->
        <object id="sessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
        <!--<property name="dbProvider" ref="dbProvider"/>
            <property name="HibernateProperties">
               <dictionary>
            <entry key="" value="" />
                  <entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
                  <entry key="hibernate.dialect" value="NHibernate.Dialect.MySQLDialect"/>
                  <entry key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver"/>
               </dictionary>
            </property>-->
         </object>
     
         <object id="hibernateTransactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate12">
            <!--<property name="dbProvider" ref="dbProvider"/>-->
            <property name="sessionFactory" ref="sessionFactory"/>
         </object>
      </objects>
   </spring>

  <nhibernate>
    <!-- untenstehendes mit einer klasse im config-ordner -->
    <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
    <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
    <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
    <add key="hibernate.connection.connection_string"
      value="Data Source=YOUR_SERVER;Database=Northwind;User ID=YOUR_USERNAME;Password=YOUR_PASSWORD;" />
    <add key="hibernate.connection.isolation" value="ReadCommitted" />
    <add key="hibernate.default_schema" value="Northwind.dbo" />

    [b]<!--<mapping file="Customer.hbm.xml" />-->[/b]
  </nhibernate>
 
 
   <appSettings/>
   <connectionStrings/>
   <system.web>
    <httpHandlers>
      <!--<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web" />-->
    </httpHandlers>
    <httpModules>
      <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" />
    </httpModules>

      <compilation debug="true">
         <assemblies>
            <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
      </compilation>
      <authentication mode="Windows"/>
   </system.web>
</configuration>



the problem is, that i always get the following error:
Quote:
Server Error in '/testMan' Application.
--------------------------------------------------------------------------------

Unknown entity class: Domain.Customer
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: Unknown entity class: Domain.Customer


if i uncomment the following line in the<nhibernate>-section (<!--<mapping file="Customer.hbm.xml" />-->) in the file above (Web.Config) i get the following error:
Quote:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized element.

Source Error:


Line 65: <add key="hibernate.default_schema" value="Northwind.dbo" />
Line 66:
Line 67: <mapping file="Customer.hbm.xml" />
Line 68: </nhibernate>
Line 69:


Source File: D:\testMan\web.config Line: 67


i really don't have an idea what could be wrong. i already asked uncle google and mr. search from hibernate, but i didn't get any reliable answers....

thank you very much for your help.


Top
 Profile  
 
 Post subject: Re: newbie web.config help "NHibernate.MappingException
PostPosted: Thu Mar 01, 2007 12:19 pm 
Newbie

Joined: Thu Mar 01, 2007 12:01 pm
Posts: 2
Location: Russia, Nizhny Novgorod (Moscow)
I have the same problem and don't mind how to solve it :(
I've added mine Miscellaneous.hbm.xml to the project resources.
One note: i've catched that if you store your Class file at the App_Code, you should specify it in mapping at the Web.config:
Code:
<mapping assembly="[b]App_Code[/b].QuickStart"/>

otherwise you'll get an Exception.

Any help would be great!

Thnx.


Top
 Profile  
 
 Post subject: Re: newbie web.config help "NHibernate.MappingException
PostPosted: Fri Mar 02, 2007 5:17 am 
Newbie

Joined: Thu Mar 01, 2007 12:01 pm
Posts: 2
Location: Russia, Nizhny Novgorod (Moscow)
Whow! It works for me :)
All, what you should do is:
1) Create solution under VS
2) Add your web site there
3) Add a library where you should store your business logic
4) Set your web site as Start-up Project
5) Copy all the necessary NHibernate dlls (i copied all of them) to the /bin of a web site
6) Add a reference to your business logic project to the web site project
7) Configure Web.config to use NHibernate and place there a mapping to your business logic assembly.
8) Create NHibernateHelper (from a help docs sample)
9) Create mapped class & related xxx.hbm.xml at the business logic project and make xml Embedded in order to make it runtime accessible.

That's all :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 03, 2007 9:28 am 
Newbie

Joined: Wed Feb 28, 2007 9:54 am
Posts: 2
hi,

thanks for your reply.

but: the error "Unrecognized element." further exists. furthermore, i don't have a file-property "build action" in my visual studio 2005 web developer express edition... i read that this option doesn't exist anymore... is that true?

how can i do this in an other way?


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