Easing the pain with FluentConfigurationException - possible fixes

7 views
Skip to first unread message

Alex

unread,
Dec 15, 2009, 3:40:17 PM12/15/09
to Fluent NHibernate
Hi,

My question is regarding debugging techniques for
FluentConfigurationExceptions when using Automappings. The crux of my
issue is listed on StackOverFlow:
http://stackoverflow.com/questions/1909880/fluent-nhibernate-debugging-fluentconfigurationexception

When using a fluent configuration, this exception seems to pop up
everywhere and can have a variety of different causes. Sometimes
drilling into the InnerExceptions helps, sometimes not. I've never
seen the PotentialReasons collection contain a single item. I was
wondering is there any way to get a better grip on what FNH is trying
to do when it crashes and burns this way? Is it currently possible to
have FNH output a detailed log of what part of my code it's tripping
up on?

Are there any efforts underway to improve this situation? I'd be happy
to contribute some code if a general approach has been outlined.



James Gregory

unread,
Dec 15, 2009, 4:29:01 PM12/15/09
to fluent-n...@googlegroups.com
Fluent NHibernate != NHibernate. We're just a layer ontop of NH. Once we pass off our mappings to NH, there's little we can do. We have plans to put in a validation layer to try to catch the obvious cases (like missing Id) before we pass off to NH, but the cryptic exceptions aren't our doing.

As far as I'm aware, there aren't any cases where there won't be an InnerException; the exception is raised only when an NHibernate exception is bubbled up. The PotentialReasons collection contains items when you haven't configured something through the Fluently.Configure API. It currently doesn't contain any details about the mappings themselves.




--

You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.



Alex

unread,
Dec 16, 2009, 1:01:02 AM12/16/09
to Fluent NHibernate
Ok thanks for the clarification. Is this something that could be
handled by code contracts in the next .NET? Or are there too many
permutations to make this feasible?

On Dec 16, 5:29 am, James Gregory <jagregory....@gmail.com> wrote:
> Fluent NHibernate != NHibernate. We're just a layer ontop of NH. Once we
> pass off our mappings to NH, there's little we can do. We have plans to put
> in a validation layer to try to catch the obvious cases (like missing Id)
> before we pass off to NH, but the cryptic exceptions aren't our doing.
>
> As far as I'm aware, there aren't any cases where there won't be an
> InnerException; the exception is raised only when an NHibernate exception is
> bubbled up. The PotentialReasons collection contains items when you haven't
> configured something through the Fluently.Configure API. It currently
> doesn't contain any details about the mappings themselves.
>
>
>
> On Tue, Dec 15, 2009 at 8:40 PM, Alex <alex....@gmail.com> wrote:
> > Hi,
>
> > My question is regarding debugging techniques for
> > FluentConfigurationExceptions when using Automappings. The crux of my
> > issue is listed on StackOverFlow:
>
> >http://stackoverflow.com/questions/1909880/fluent-nhibernate-debuggin...
>
> > When using a fluent configuration, this exception seems to pop up
> > everywhere and can have a variety of different causes. Sometimes
> > drilling into the InnerExceptions helps, sometimes not. I've never
> > seen the PotentialReasons collection contain a single item.  I was
> > wondering is there any way to get a better grip on what FNH is trying
> > to do when it crashes and burns this way? Is it currently possible to
> > have FNH output a detailed log of what part of my code it's tripping
> > up on?
>
> > Are there any efforts underway to improve this situation? I'd be happy
> > to contribute some code if a general approach has been outlined.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-n...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>
> > .

Paul Batum

unread,
Dec 16, 2009, 7:05:47 AM12/16/09
to fluent-nhibernate
I don't think code contracts would help too much here. They could help
us make FNH less buggy, but that is a different matter. I believe the
best way forward (as James mentioned) is a validation layer built in
FNH that specifically looks for common mapping errors.
> To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

tbushell

unread,
Dec 16, 2009, 3:47:50 PM12/16/09
to Fluent NHibernate


On Dec 15, 4:29 pm, James Gregory <jagregory....@gmail.com> wrote:
> Fluent NHibernate != NHibernate. We're just a layer ontop of NH. Once we
> pass off our mappings to NH, there's little we can do. We have plans to put
> in a validation layer to try to catch the obvious cases (like missing Id)
> before we pass off to NH, but the cryptic exceptions aren't our doing.

That sounds like a great idea. Automapping is a terrific technology,
but, IMO, is being hamstrung by arcane error messages. There have
been seveal times in the last few weeks I've been on the verge of
chucking it. (Glad I didn't - thanks again to the people on this list
who helped me out!)

One of the biggest problems I see is that there's often no indication
of which class or member that is causing the error.

Would it be worthwhile if several of we Fluent NH users submitted
requests to the NH team to put more specific info in their error
messages (e.g. which class, which member, etc)?

-Tom

James Gregory

unread,
Dec 16, 2009, 3:50:34 PM12/16/09
to fluent-n...@googlegroups.com
The NHibernate exceptions actually do contain a lot of information, including the types. You just need to know how to read them. As the exceptions are actually XML Schema violations, they can take some peculiar forms, but once you understand what the schema is they're pretty easy.

Vadim Kantorov

unread,
Dec 16, 2009, 4:30:26 PM12/16/09
to Fluent NHibernate
Just about the XML Validation problems.
Here are two defects that need to be fixed.
http://groups.google.ru/group/fluent-nhibernate/browse_thread/thread/edb98819243e89b0

I'm going to prepare a patch at the weekend.
> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr­i...@googlegroups.com>
> > .

tbushell

unread,
Dec 17, 2009, 12:26:40 PM12/17/09
to Fluent NHibernate

On Dec 16, 3:50 pm, James Gregory <jagregory....@gmail.com> wrote:
> The NHibernate exceptions actually do contain a lot of information,
> including the types. You just need to know how to read them. As the
> exceptions are actually XML Schema violations, they can take some peculiar
> forms, but once you understand what the schema is they're pretty easy.

Not sure I understand. The NHibernate message (taken from the Alex's
Stack Overflow post) was:

{"(XmlDocument)(3,6): XML validation error: The element 'class' in
namespace 'urn:nhibernate-mapping-2.2' has invalid child element
'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible
elements expected: 'meta, subselect, cache, synchronize, comment,
tuplizer, id, composite-id' in namespace 'urn:nhibernate-
mapping-2.2'."}


I use an "ExportTo" in my configuration, which saves the XML mapping
files to disk. Are you saying that by examining these files we can
determine which class failed to map?

If so, do we have to scan every file, looking for the one that has a
problem? Or is there some clue in the message thrown by NHibernate
that will tell us which class is failing (to me, all the info in the
message above looks very generic).

I'd love to get a better handle on this, and would appreciate any
light you can shed on the issue.

-Tom


>
>
>
> On Wed, Dec 16, 2009 at 8:47 PM, tbushell <tbush...@bic.com> wrote:
>
> > On Dec 15, 4:29 pm, James Gregory <jagregory....@gmail.com> wrote:
> > > Fluent NHibernate != NHibernate. We're just a layer ontop of NH. Once we
> > > pass off our mappings to NH, there's little we can do. We have plans to
> > put
> > > in a validation layer to try to catch the obvious cases (like missing Id)
> > > before we pass off to NH, but the cryptic exceptions aren't our doing.
>
> > That sounds like a great idea.  Automapping is a terrific technology,
> > but, IMO, is being hamstrung by arcane error messages.  There have
> > been seveal times in the last few weeks I've been on the verge of
> > chucking it.  (Glad I didn't - thanks again to the people on this list
> > who helped me out!)
>
> > One of the biggest problems I see is that there's often no indication
> > of which class or member that is causing the error.
>
> > Would it be worthwhile if several of we Fluent NH users submitted
> > requests to the NH team to put more specific info in their error
> > messages (e.g. which class, which member, etc)?
>
> > -Tom
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-n...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr­i...@googlegroups.com>


> > .
> > For more options, visit this group at

> >http://groups.google.com/group/fluent-nhibernate?hl=en.- Hide quoted text -
>
> - Show quoted text -

Paul Batum

unread,
Dec 17, 2009, 4:18:11 PM12/17/09
to fluent-n...@googlegroups.com
That error is basically saying that you forgot to map an ID. Not very clear I know! I do think NHibernate could do a better job with its error messages, and of course FNH could do some sanity checks to prevent the user from getting as far as schema validation with a dodgy mapping. All in good time, I guess.

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

tbushell

unread,
Dec 18, 2009, 2:58:35 PM12/18/09
to Fluent NHibernate

On Dec 17, 4:18 pm, Paul Batum <paul.ba...@gmail.com> wrote:
> That error is basically saying that you forgot to map an ID. Not very clear
> I know!

Yeah, it's bad on so many levels:

- It lists 8 possible elements that could be missing
- the most common one, Id, is buried near the end of the list
- it doesn't tell you which class is missing the element


> I do think NHibernate could do a better job with its error messages,

Absolutely. I'll probably submit this as a bug to the NHibernate
guys, and see what they say.

> and of course FNH could do some sanity checks to prevent the user from
> getting as far as schema validation with a dodgy mapping.

If FNH just flagged missing Id members, and things it didn't know how
to map, that would go a long way to solving the problem. Easy for me
to say, of course, having no idea of how much work is really
involved... ;-)

-Tom

> > > >http://groups.google.com/group/fluent-nhibernate?hl=en.-Hide quoted

Mikael Henriksson

unread,
Dec 19, 2009, 9:35:13 AM12/19/09
to fluent-n...@googlegroups.com
First of all there is very little information from the error messages if you are using the ms tests. When I switched to nunit I get the full exception logged. Also a good idea is to run to catch the exceptions with log4net which should give you even more information about what actually happened. When I switched to log4net and nunit I had no problems what so ever finding the source of the issues.

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

tbushell

unread,
Dec 19, 2009, 5:35:16 PM12/19/09
to Fluent NHibernate

On Dec 19, 9:35 am, Mikael Henriksson <mik...@zoolutions.se> wrote:
> When I switched to log4net and nunit I had no problems what so ever finding
> the source of the issues.

I'm getting the full exception via the VS2008 debugger, so don't think
that's an issue.

Had no luck getting log4net running a few weeks back, but think I have
some better documentation now.

I'll try again - thanks for the suggestion.

-Tom

Reply all
Reply to author
Forward
0 new messages