-->
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: Namespace prefix 'hbm' is not defined
PostPosted: Sat Oct 27, 2007 9:07 am 
Newbie

Joined: Thu Oct 11, 2007 4:18 pm
Posts: 2
Hi,
I'm using nHibernate 1.2 and asp.net 2.0 (and asp.net ajax, if it matters)
Generally, it works ok, but from time to time I get this exception:
Namespace prefix 'hbm' is not defined
while adding assembly that contains mapping files:
Code:
Configuration cfg = new Configuration();
foreach( string assemb in assemblies )
cfg.AddAssembly( assemb ); // HERE IS ERROR

I do this in my IHttpModule, in the BeginRequest event handler. The thing is, this exception is unpredictible (sometime everything works for a while, I can browse pages etc) and occurs when nHibernate compiles different classes (so one time it's during Users.hbm.xml compilation, the other time it's Page.hbm.xml and so on).
What's up? Anyone have any idea?
thanks in advance
chris


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 31, 2007 9:40 am 
Beginner
Beginner

Joined: Wed Aug 29, 2007 1:25 pm
Posts: 26
Location: Recife, PE, Brazil
hi..

between this line

cfg.AddAssembly( assemb );

you could code an Exception code that would show the Stack trace..message exceptions from the Exception and its all InnerException

it could help in order to make sure where the problem is


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 01, 2007 12:22 pm 
Newbie

Joined: Thu Oct 11, 2007 4:18 pm
Posts: 2
Thanks for your interest!
The most outer exception is:
Code:
{"Could not compile the mapping document: Hmm.DTO.Core.AspNet.mappings.Events.hbm.xml"}

thrown by NHibernate, with this stack trace:
Code:
   at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me)
   at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name)
   at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name)
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
   at NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly)
   at NHibernate.Cfg.Configuration.AddResources(Assembly assembly, IList resources, Boolean skipOrdering)
   at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly, Boolean skipOrdering)
   at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)
   at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName)
   at Hmm.DAO.Common.NHibernateSessionManager.InitSessionFactory(String[] assemblies) in c:\moje\Programowanie\agro\Hmm\DAL\Common\NHibernateSessionManager.cs:line 63
   at Hmm.DAO.DAOManager.HmmSessionManager.BeginTransaction(Object sender, EventArgs e) in c:\moje\Programowanie\agro\Hmm\DAL\DAOManager\HmmSessionManager.cs:line 20
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


while the only inner exception is:
Code:
{"Namespace prefix 'hbm' is not defined."}

thrown by:
Code:
   at MS.Internal.Xml.XPath.CompiledXpathExpr.UndefinedXsltContext.LookupNamespace(String prefix)
   at MS.Internal.Xml.XPath.BaseAxisQuery.SetXsltContext(XsltContext context)
   at MS.Internal.Xml.XPath.CompiledXpathExpr.SetContext(XmlNamespaceManager nsManager)
   at System.Xml.XmlNode.SelectSingleNode(String xpath, XmlNamespaceManager nsmgr)
   at NHibernate.Cfg.HbmBinder.HandleCustomSQL(XmlNode node, PersistentClass model)
   at NHibernate.Cfg.HbmBinder.BindClass(XmlNode node, PersistentClass model, Mappings mappings)
   at NHibernate.Cfg.HbmBinder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
   at NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings mappings)
   at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name)


The xml file itself:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Hmm.DTO.Core" namespace="Hmm.DTO.Core.AspNet.WebEvents">
   <class name="Events" table="aspnet_WebEvent_Events">

      <id name="EventId" column="EventId" type="System.String">
         <generator class="assigned"/>
      </id>
      <property column="EventTimeUtc" type="System.DateTime" name="EventTimeUtc" not-null="true" />
....
   </class>
</hibernate-mapping>


It is very annoying. This hbm.xml document is not the only one that throws the same exception - it looks like random classes at random time throws the exception. I'm using ASP.NET 2.0 + AJAX web extensions and SQL 2005 EXPRESS. NHibernate is 1.2. All of my mapping files are marked as Embeded Content.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 05, 2008 5:22 pm 
Newbie

Joined: Thu Nov 15, 2007 5:06 pm
Posts: 5
I'm having the same issue.

Was there any resolution to this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 06, 2008 2:15 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
Please post your Mapping, which causes the exception.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 1:29 pm 
Newbie

Joined: Thu Nov 15, 2007 5:06 pm
Posts: 5
I did a little let work, looking at the NHibernate source, and found that the only similarity between my issue and the one above is:

System.Xml.XmlNode.SelectSingleNode(String xpath, XmlNamespaceManager nsmgr)

In my case, the NHibernate function calling this is HbmBinder.GetTypeFromXML().


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 5:47 pm 
Newbie

Joined: Thu Nov 15, 2007 5:06 pm
Posts: 5
bhartsock wrote:
I did a little let work, looking at the NHibernate source, and found that the only similarity between my issue and the one above is:

System.Xml.XmlNode.SelectSingleNode(String xpath, XmlNamespaceManager nsmgr)

In my case, the NHibernate function calling this is HbmBinder.GetTypeFromXML().


Just to follow up, I found a bug in my code that caused the NHibernate.Cfg.Configuration object to be created every page hit. The session factory was only built on the first page hit though.

What I am guessing is this exposed a threading issue in the Configuration object that normally never be hit since it is created once and that is all. After making the change, I haven't seen any errors. I will post back if I do.


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.