unmapped class error

705 views
Skip to first unread message

Raymond Camden

unread,
Oct 30, 2009, 4:20:10 PM10/30/09
to cf-or...@googlegroups.com
I'm working on a project called Picard. In my app.cfc I created a
mapping named picard that points to my application root. Normally I
call this mapping root or app, but for whatever reason, I didn't do
that this time.

At my model layer, I've got various subfolders to help organize all my
CFCs. If a CFC in the user folder has a relationship to a CFC in the
page folder, than I'l have a link like so:

cfc="picard.model.page.page"

This works fine - but it bugs me. I added a new mapping called model
that points to my model folder. I added a new CFC with the following
property:

property name="user" fieldtype="many-to-one" cfc="model.user.user"
fkcolumn="useridfk";

But when run, I get:

An association from the table comment refers to an unmapped class:

Changing cfc to picard.model.user.user fixes the issue, but I'd really
rather use just the model mapping.

Any ideas?


--
===========================================================================
Raymond Camden, ColdFusion Jedi Master

Email : r...@camdenfamily.com
Blog : www.coldfusionjedi.com
AOL IM : cfjedimaster

Keep up to date with the community: http://www.coldfusionbloggers.org

Raymond Camden

unread,
Oct 30, 2009, 4:39:50 PM10/30/09
to cf-or...@googlegroups.com
So I commented it out that property, and later on I use another property:

property name="file" fieldtype="one-to-one" cfc="model.file.file"
fkcolumn="fileidfk";

and this works just fine. So the model mapping must be ok.

Rupesh Kumar

unread,
Oct 31, 2009, 1:49:38 AM10/31/09
to cf-or...@googlegroups.com
Here is what happened.
ORM takes the CFC name from the CFC metadata and the name remains same as long as the class file for the CFC is loaded.
You had only one application mapping earlier - "picard" and hence the CFC's qualified name gets stored as "picard.model.page.page". When you defined another application mapping "model", the new qualified name will not be stored in the metadata if it was already created and hence ORM will not know about it.
That is why ORM will complain that this CFC is not mapped.

The way to fix that will be to change the CFC files so that its classes are re-generated and the metadata is reloaded.

Rupesh.

Raymond Camden

unread,
Oct 31, 2009, 12:30:30 PM10/31/09
to cf-or...@googlegroups.com
So basically just edit the file and resave?

Raymond Camden

unread,
Oct 31, 2009, 12:42:39 PM10/31/09
to cf-or...@googlegroups.com
Also - with two mappings, how will CF know which to use for the qualified name?

On Sat, Oct 31, 2009 at 12:49 AM, Rupesh Kumar <ruk...@adobe.com> wrote:
>

Raymond Camden

unread,
Oct 31, 2009, 2:02:42 PM10/31/09
to cf-or...@googlegroups.com
Editing user.cfc did not fix the problem.

Raymond Camden

unread,
Oct 31, 2009, 2:05:33 PM10/31/09
to cf-or...@googlegroups.com
Also - I modified my app.cfc to do:

<cfset this.mappings["/picard"] =
getDirectoryFromPath(getCurrentTemplatePath())>
<cfset this.mappings["/model"] =
getDirectoryFromPath(getCurrentTemplatePath()) & "model/">
<cfset foo = createObject("component", "model.user.user")>
<cfdump var="#foo#"><cfabort>

And it correctly found the CFC.

Raymond Camden

unread,
Oct 31, 2009, 2:07:40 PM10/31/09
to cf-or...@googlegroups.com
Ugh - now I get the error within another entity - group, and as group
has a lot of properties, I have no idea which one is wrong. The error
says:

An association from the table group refers to an unmapped class:

How do I know _which_ association?

Raymond Camden

unread,
Oct 31, 2009, 2:15:06 PM10/31/09
to cf-or...@googlegroups.com
And even better - in an act of desperation I went ahead and removed
any use of picard.model.X. I edited them all to be model.X. Now I get
this on startup:

Association references unmapped class:

No detail on _where_ the association is or _what_ it is trying to use.
This error is about as useless as it can get.

Shannon Hicks

unread,
Oct 31, 2009, 2:19:33 PM10/31/09
to cf-orm-dev
Here's what I have working:

All my mappings just say cfc="SomeObject" without the mappings

In my application.cfc, I've got:

THIS.ormsettings.cfclocation = "/myMapping/model";

Everything works fine, until I try the "new someObject();" syntax. I
have to first do:

import "myMapping.model.*";

Shan

Raymond Camden

unread,
Oct 31, 2009, 2:31:54 PM10/31/09
to cf-or...@googlegroups.com
The problem is though that I have multiple folders under model: user,
resource, page, etc. So if user.user needs to map to
resource.something, it needs a full path (afaik).

Shannon Hicks

unread,
Oct 31, 2009, 2:40:56 PM10/31/09
to cf-orm-dev
Ahh, I understand your problem now.

On a related subject, have you taken a step back to consider if you
need those sub folders? I mean, do they just each have one file in
them?

Raymond Camden

unread,
Oct 31, 2009, 2:45:31 PM10/31/09
to cf-or...@googlegroups.com
Yep, I need em. My model layer is pretty big now. It would be pretty
messy without.

Raymond Camden

unread,
Oct 31, 2009, 2:46:38 PM10/31/09
to cf-or...@googlegroups.com
Ok, more data.

I turned on the config setting to save the hbmxml files. I still see
picard.model.x in there even though it is nowhere to be found in the
CFC. So I picked one CFC, grouptype, and added a new property, just
for the heck of it. On reload, the hbmxml file was NOT refreshed with
the new prop and still had the incorrect path in it.

Shannon Hicks

unread,
Oct 31, 2009, 2:49:10 PM10/31/09
to cf-orm-dev
If I remember correctly, CF never refreshes a hbmxml file. You have to
delete it for CF to recreate it.

Raymond Camden

unread,
Oct 31, 2009, 2:49:34 PM10/31/09
to cf-or...@googlegroups.com
I had to delete the hbmxml file to see it reflected. Is that normal?
That means using savemapping means you need to delete all your hbmxml
files if you make changes (or maybe just the one).

Unfortunately - the xml contains the new prop, but NOT the right pathing.

--

Shannon Hicks

unread,
Oct 31, 2009, 2:56:36 PM10/31/09
to cf-orm-dev
Yes, that's expected. I would assume they did it so that if you use
custom hbmxml files you don't accidentally overwrite them by changing
a CFC.

Shan

Raymond Camden

unread,
Oct 31, 2009, 2:57:44 PM10/31/09
to cf-or...@googlegroups.com
-sigh-

Ok, so I manually edited about 30 lines of hbmxml. I now get a new
error on startup:


Entity Name imagepanel is same for two CFCs,
picard.model.page.imagepanel and model.page.imagepanel.

WTF - why is CF "holding" on to the other mapping? I'd like to get rid
of picard, but even if I rename it, it's still a mapping I need
anyway.

Raymond Camden

unread,
Oct 31, 2009, 2:58:38 PM10/31/09
to cf-or...@googlegroups.com
Oh sweet - reloaded, and it's back to

Association references unmapped class:

Grrrr, these vague errors are really frustrating.

Raymond Camden

unread,
Oct 31, 2009, 3:08:16 PM10/31/09
to cf-or...@googlegroups.com
At this point I'm just considering giving up. I'll rename picard to
"app" and use app.model.etc in all my code.

Raymond Camden

unread,
Oct 31, 2009, 3:34:14 PM10/31/09
to cf-or...@googlegroups.com
Well, I did it. I gave up. I used one main mapping, root, removed all
instances of picard, and switched all my entity cfcs that use
relationships to use root.model.x.y.

But still - I'd like to know - is there something fundamentally wrong
with using 2 mappings in a CF app? I'll also add that I restarted CF
about 5 times while testing and it never seemed to help. CF was
_insistent_ that my CFCs were picard.something, not model.something.

Kurt Wiersma

unread,
Oct 31, 2009, 4:26:11 PM10/31/09
to cf-or...@googlegroups.com
I have actually run into a similar issue on CF 8 when using a cfc with
a couple of different mapping to the application root. What has work
for me under CF 8 is to hit the "Clear template cache" button in the
CF admin. Then you could try an ORM refresh and see if that works.

--Kurt

Andrew Scott

unread,
Oct 31, 2009, 5:45:05 PM10/31/09
to cf-or...@googlegroups.com
Ray,
 
Correct me if I am wrong.
 
picard.model.page.imagepanel and model.page.imagepanel
 
Unless you have defined a separate table name, will throw that error. The reason being is if you strip away the FQN you are left with imagePanel both trying to go into the databse. So this is expected.
 
Regards
Andrew Scott

Raymond Camden

unread,
Nov 1, 2009, 9:23:13 AM11/1/09
to cf-or...@googlegroups.com
I didn't use both though. That error came from CF, not my code.
Nowhere in my CFCs did anything create picard.x or map to picard.x. CF
"hung on" to the definition, even after I restarted, cleared cache,
etc.

Tony Nelson

unread,
Nov 1, 2009, 10:31:14 AM11/1/09
to cf-orm-dev
Here's my understanding of what's going on, with a little help from
the docs (http://help.adobe.com/en_US/ColdFusion/9.0/Developing/
WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html):

When you load up your application, Hibernate will look for all of your
persistent entities and automatically create a mapping for each
persistent CFC it finds. By default, it will look "at the application
directory, its sub-directories, and its mapped directories to search
for persistent CFCs". I assume it scans in that order, so in your case
it will find the CFC in the sub-directory before it finds it in the
mapped directory. If you want to limit the paths where ColdFusion will
look, you can change this.ormsettings.cfclocation to the location(s)
of your choice.

If you turn on this.ormsettings.savemapping, ColdFusion will save the
*.hbmxml files it generates. Once saved, Hibernate will use this file
to configure your mapping. If you update your CFC, the changes will
not be reflected inside your *.hbmxml file since you might've made
other changes to the XML that your component isn't aware of.

As for the "Entity Name imagepanel is same for two CFCs,
picard.model.page.imagepanel and model.page.imagepanel", here's my
theory. The first time your application loaded, it found the CFC
located at picard.model.page.imagepanel and generated the
ImagePanel.hbmxml for you. Then I'm guessing you updated the
ImagePandel.hbmxml file and changed your class definition from
name="cfc:picard.model.page.imagepanel" to
name="cfc:model.page.imagepanel". Then the next time your reloaded
your application, Hibernate threw the error. This happened because
ColdFusion scanned your directories and found the persistent
ImagePanel.cfc located at picard.model.page.imagepanel. It then
checked the config to see if there was already an entity with a name
mapped to "cfc:picard.model.page.imagepanel". Since it didn't find
one, it created the mapping again, unaware that another Hibernate
mapping was pointing to the same CFC via a ColdFusion mapping. Now
Hibernate had 2 "ImagePanel" mappings, which will throw an error.

How do you get around this? The easy way would be to always reference
the full dot-notated path "picard.model.page.imagepanel" inside your
CFCs, which I believe is the route you took. Personally, I prefer to
keep my CFCs clean of any relationship details and use the *.hbmxml
files for all my application configuration. I'll typically have
ColdFusion initially generate the mappings to get me started, but then
I'll copy the content into /config/hibernate.xml. That way I have all
my configuration in one spot, rather than scattered throughout my
model inside CFCs.

As a side note, if you really want to use the /model mapping inside
your *.hbmxml file(s), you could set this.ormsettings.autogenmap to
false and ColdFusion won't scan your application and create the
duplicate mappings.

Hopefully that made some sense.
-Tony

On Nov 1, 8:23 am, Raymond Camden <rcam...@gmail.com> wrote:
> I didn't use both though. That error came from CF, not my code.
> Nowhere in my CFCs did anything create picard.x or map to picard.x. CF
> "hung on" to the definition, even after I restarted, cleared cache,
> etc.
>

Rupesh Kumar

unread,
Nov 2, 2009, 6:00:16 AM11/2/09
to cf-or...@googlegroups.com
Ray,
Not sure what is going on. AFAIK, we find the best match for finding the cfc fully qualified name and therefore in this case, the cfc name should evaluate to "model.page.imagepanel". Could you please log a bug for this so that we can investigate and track it.

Rupesh

Sumit Verma

unread,
Dec 27, 2009, 9:05:18 AM12/27/09
to cf-orm-dev
Hey Guys,

Was this bug reported? This is so frustrating. I went through the same
frustrating steps as Ray. The irony is I did remembered seeing this
thread, but still kept trying (argh...). I have 2 mapping in my
application.cfc as well (appRoot, com). I would like to use
com.model.x.y for my entities and I need appRoot mapping for some
other things in my app.

It seems like there is no _set_ order in which entities are found.
Some time they are evaluated to com and some time to appRoot. I even
tired using cfclocation attribute (=com), but that didn't made any
difference.

After wasting too many hours, I'm giving up too and going to use just
one mapping (appRoot). I do hope that this gets fixed soon so we can
use multiple mapping in our application!!

Sumit


On Nov 2, 6:00 am, Rupesh Kumar <ruku...@adobe.com> wrote:
> Ray,
> Not sure what is going on. AFAIK, we find the best match for finding the cfc fully qualified name and therefore in this case, the cfc name should evaluate to "model.page.imagepanel". Could you please log a bug for this so that we can investigate and track it.
>
> Rupesh
>
>
>
> -----Original Message-----
> From: cf-or...@googlegroups.com [mailto:cf-or...@googlegroups.com] On Behalf Of Raymond Camden
> Sent: Sunday, November 01, 2009 7:53 PM
> To: cf-or...@googlegroups.com
> Subject: Re: unmapped class error
>
> I didn't use both though. That error came from CF, not my code.

> Nowhere in my CFCs did anything createpicard.x or map topicard.x. CF


> "hung on" to the definition, even after I restarted, cleared cache,
> etc.
>

Henry Ho

unread,
Dec 28, 2009, 12:44:00 AM12/28/09
to cf-orm-dev
Did you try restarting the CF service? Sometimes ORMReload() is not
enough.

Henry

Sumit Verma

unread,
Dec 28, 2009, 12:47:14 AM12/28/09
to cf-or...@googlegroups.com
Yes, I did many times...

--

You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To post to this group, send email to cf-or...@googlegroups.com.
To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cf-orm-dev?hl=en.



Steve Rittler

unread,
Feb 10, 2010, 10:50:58 AM2/10/10
to cf-orm-dev
Was there any further discussion on this topic? I have not located a
bug in the bugtracker (even if it's just documentation to tell us what
the path search order is).

I'm running in to the same situation as Sumit. I'm building a new app
to be deployed on a server instance with a pile of legacy spaghetti
code that uses a CF mapping to the site root. Unfortunately, even
with that same mapping reassigned to a different path in my
Application.cfc (and cfclocation defined for my app) I am getting an
"assocation references unmapped class" on the first load of the app.
3 of my 7 persistent CFCs are somehow acquiring the wrong fully
qualified name (per the hbmxml files).

Hitting refresh allows the app to startup and run properly (I'm
assuming that's because Hibernate now knows where they are there's no
confusion over building the relationships internally). I would,
however, like to avoid the initial startup blowup by resolving this
properly.

Bugworthy or is anyone interested in trying to hammer it out here?

Steve

Sumit Verma

unread,
Feb 10, 2010, 1:49:35 PM2/10/10
to cf-or...@googlegroups.com
I gave up and ended up using a single mapping...

Rupesh Kumar

unread,
Feb 11, 2010, 4:46:36 AM2/11/10
to cf-or...@googlegroups.com

can you log a bug for this and add the repro case for the same?

 

Could you also send the repro case to me directly at rukumar at adobe dot com?

 

Rupesh

Steve Rittler

unread,
Feb 11, 2010, 7:58:13 AM2/11/10
to cf-orm-dev
Sure, i'll get that put together today.

Aaron Greenlee

unread,
Nov 9, 2011, 9:47:23 AM11/9/11
to cf-or...@googlegroups.com
Not quite sure If I am having the same issue, but, thought I'd tag on to this thread in case I missed something.

On the first request to my application I sometimes get an error similar to the one reported here: "An association refers to an unmapped class first loadAn association from the table AUDIT_EVENTS refers to an unmapped class" All subsequent requests do not have an issue and work as expected. I'm guessing I get this error 50% of the time. 

There are no ColdFusion server mappings. Just application mappings.

Any rock-stars have advice?

Thanks!

Aaron

Scott Smith

unread,
Nov 9, 2011, 11:30:49 AM11/9/11
to cf-or...@googlegroups.com
I can confirm we experience this as well.  I thought the issue originally was related to the fact that we had more than one mapping that could theoretically reach the object setup in the administrator settings, and it seemed to choose the wrong one sporadically.  Then I defined the intended path as a mapping directly on the application.cfc and the problem seemed to go away.  However, we are seeing it more and more when reloading after a release just as you described.  Often times, we just reload again and it works fine.  On one occasion after reloading, it threw the error again but for a different object, then after reloading again it seemed to bring the server to a halt.  I ended having to restart the instance that time, and then it worked first try. 

--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cf-orm-dev/-/00WVF7oVvrwJ.

Tom Bishop

unread,
Aug 16, 2013, 10:37:31 AM8/16/13
to cf-or...@googlegroups.com, rca...@gmail.com
Hi,

I also experienced this error and it turned out to be having a mapping that referred to the application, whilst the app folder in IIS having a different name. I removed the mapping but it kept on throwing the error. I then did a server restart and it resolved itself. Had me pulling my hair for a fair while though.

On Monday, 20 August 2012 12:11:58 UTC+1, Kirill Grishin wrote:
Just want to add that on CF10 there is still the same issue. Once I switched to a single mapping everything worked.

On Saturday, October 31, 2009 5:20:10 AM UTC+9, Raymond Camden wrote:
I'm working on a project called Picard. In my app.cfc I created a
mapping named picard that points to my application root. Normally I
call this mapping root or app, but for whatever reason, I didn't do
that this time.

At my model layer, I've got various subfolders to help organize all my
CFCs. If a CFC in the user folder has a relationship to a CFC in the
page folder, than I'l have a link like so:

cfc="picard.model.page.page"

This works fine - but it bugs me. I added a new mapping called model
that points to my model folder. I added a new CFC with the following
property:

        property name="user" fieldtype="many-to-one" cfc="model.user.user"
fkcolumn="useridfk";

But when run, I get:

An association from the table comment refers to an unmapped class:

Changing cfc to picard.model.user.user fixes the issue, but I'd really
rather use just the model mapping.

Any ideas?

Samuel W. Knowlton

unread,
Feb 12, 2014, 12:43:23 PM2/12/14
to cf-or...@googlegroups.com
We have something like this issue that came up with a transition from a legacy app to an ORM-aware app in the middle of last year. We have all our ORM Entities in a /model/ORM/ folder, but one of them - the newest one - never maps correctly after a server restart. It DOES map correctly if we do an ORMReload().

There is nothing odd or unique about it in the whole object model - not a duplicate name or anything.

I hope that debugging errors like this is made a little more accessible in CF11!

Joe Mesot

unread,
May 31, 2015, 2:04:19 PM5/31/15
to cf-or...@googlegroups.com, rca...@gmail.com
So I know this thread is really old, but we are building a new cms system and we keep getting this same error all the time, and with it being so vague I have no idea how or where to start.

I have read through all the comments and suggestions here as well as other posts around the internet. I have cleared template cache in CF Admin. My last resort is to post here with my application details and hopefully get some resolution.

The mappings definitely seem to be a problem as everyone has outlined here. I am mostly a front end developer, but my boss has me working out this issue, so I am not as familiar with all of this as I should be I guess, but here goes.

We have a two mappings setup in the CF admin as such:
/fw1core (C:/Websites/fw1cms_dev/)
/hyrule (C:/Website/fw1cms_dev/hyrule/)

inside the application.cfc we have mappings set as follows:
component extends="framework.one" {
...
this.corebase = "/fw1core";

variables.framework = {
...
diLocations = '
#this.corebase#/model/services,
#this.corebase#/utils,
#this.corebase#/model/beans,
/admin/model/services,
/app/model/services,
/app/model/beans'
// app is the default subsystem
}

this.ormsettings = {
cfclocation = ["/#variables.framework.defaultSubsystem#/model/beans","#this.corebase#/model/beans","#this.corebase#/admin/model/beans"];
}

}

folder structure looks like this:
- _fw1cms_dev
- admin
-assets
-controllers
-layouts
-model
-views
index.cfm
-framework
ioc.cfc
-hyrule
-all the sub folders for it
-model
-beans
-services

all of our beans follow this general format. When there is any relationship the cfc is simply the bean file name without the FQN.

// _fw1cms_dev/model/beans/alert.cfc
component persistent="true" cacheName="userCache" cacheUse="transactional" {

// various individual properties are here

//website many-to-many to determine which site the alert belongs to
property name="websites" fieldtype="many-to-many" cfc="website" type="array" singularname="website" linktable="website_alert" fkcolumn="alertID" inversejoincolumn="websiteID";

//categories many-to-many
property name="categories" fieldtype="many-to-many" cfc="category" type="array" singularname="category" linktable="alert_category" fkcolumn="alertID" inversejoincolumn="categoryID" inverse="true";

}

If I understand this correctly our problem lies in there being two mappings in the CF Admin with _fw1cms_dev in them and/or the cfclocation settings having more than one mapping in it.

Please advise. Thanks.

Brian Kotek

unread,
May 31, 2015, 2:47:20 PM5/31/15
to cf-or...@googlegroups.com
Not sure if this is part of the problem, but I'd always use a full package path for the CFC attributes. e.g. cfc="path.to.Category".

--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cf-orm-dev+...@googlegroups.com.

To post to this group, send email to cf-or...@googlegroups.com.

Scott Smith

unread,
May 31, 2015, 3:39:29 PM5/31/15
to cf-or...@googlegroups.com
It's been a while since I worked with CF's hibernate implementation, but I seem to remember I had some issues when relying on mappings defined in the administrator. I think I created a mapping using this.mappings in the application CFC, and then fully qualified my relationship properties relative to that.  Possibly used that application CFC mapping for the ormsettings as well. I want to say that from what I could tell, the mappings defined using this.mappings seem to supersede those defined in the administrator. 

--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cf-orm-dev+...@googlegroups.com.
To post to this group, send email to cf-or...@googlegroups.com.
Visit this group at http://groups.google.com/group/cf-orm-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Cameron Childress

unread,
Jun 1, 2015, 9:29:47 AM6/1/15
to cf-or...@googlegroups.com
On Sun, May 31, 2015 at 2:46 PM, Brian Kotek wrote:
Not sure if this is part of the problem, but I'd always use a full package path for the CFC attributes. e.g. cfc="path.to.Category".

+1

Meaning use this full package path EVERYWHERE. Return types, relationship definitions, and the component's entityname.

-Cameron
 
--
Cameron Childress
--
p:   678.637.5072
im: cameroncf
Reply all
Reply to author
Forward
0 new messages