Problem testing an application with an ORM layer in CF9

41 views
Skip to first unread message

Peter

unread,
Apr 15, 2010, 12:22:15 PM4/15/10
to mxunit
I'm running tests on my service layer that is ultimately interacting
with ORM managed objects and receiving bundled value objects from
those ORM managed objects in a few cases. If I create a simple test
page with the service calls(the calls returning the bundled objects)
and dump the response, I get the expected object back with the correct
values. When using mxunit, I received the following error which is
being thrown from the ORM object:

Exception Type: Expression | Message: Element oPropertyThatIsAnObject
is undefined in a Java object of type class [Ljava.lang.String;. |
Detail: | (error code: ) |

The method in the ORM object that is causing the exception is doing
something like this:

public SomeNewObject function toLTO(){
//create the appropiate bundled object
local.oSomeNewObject =
createObject("component","SomeNewObject").init();
//get the properties out of the ORM object
local.oSomeNewObject.prop1 = getProp1();
local.oSomeNewObject.prop2 = getProp3();
local.oSomeNewObject.prop3 = getProp4();
//prop5 is an another ORM object
local.oPropertyThatIsAnObject = getProp5();
//writeDump(local.oPropertyThatIsAnObject);abort; - good here...have
the right object
//commenting out the next 3 lines will stop the
exception when running the mxunit test
local.oSomeNewObject.prop5 =
local.oPropertyThatIsAnObject.getProp5();
local.oSomeNewObject.prop6 =
local.oPropertyThatIsAnObject.getProp6();
local.oSomeNewObject.prop7 =
local.oPropertyThatIsAnObject.getProp7();

local.oSomeNewObject
}

The only other thing to note is that the mxunit directory is not in
the application's directory but is available through a Apache
mapping....not sure if that would be causing the exception.

Marc Esher

unread,
Apr 15, 2010, 12:28:10 PM4/15/10
to mxu...@googlegroups.com
Do you have a custom RemoteFacade for your project in Eclipse? If not,
you'll need one. IT's in the Help documentation, which you can access
by clicking the green help icon on the MXUnit view.

let me know if that solves your problems.

Marc

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

Peter

unread,
Apr 15, 2010, 12:44:54 PM4/15/10
to mxunit
I do not...I'll see if that fixes this issue. Thanks for the quick
response.

On Apr 15, 12:28 pm, Marc Esher <marc.es...@gmail.com> wrote:
> Do you have a custom RemoteFacade for your project in Eclipse? If not,
> you'll need one.  IT's in the Help documentation, which you can access
> by clicking the green help icon on the MXUnit view.
>
> let me know if that solves your problems.
>
> Marc
>

Peter

unread,
Apr 15, 2010, 1:08:53 PM4/15/10
to mxunit
That allowed me to run the unit tests from inside Eclipse, but I was
running them from the url. Regardless, I'm still getting the same
ColdFusion error. It only happens when I'm trying to call the methods
on an ORM object that is a property of an ORM object.

Marc Esher

unread,
Apr 15, 2010, 1:20:58 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 1:08 PM, Peter <underad...@gmail.com> wrote:
> That allowed me to run the unit tests from inside Eclipse, but I was
> running them from the url. Regardless, I'm still getting the same
> ColdFusion error. It only happens when I'm trying to call the methods
> on an ORM object that is a property of an ORM object.

I'm no ORM expert, but it looks to me like your ORM
object-that-is-a-property simply isn't being loaded.

what happens if you write a scratch CFM page under your app, and try
to do what you're doing?

denstar

unread,
Apr 15, 2010, 1:18:58 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 10:22 AM, Peter wrote:
...

> The only other thing to note is that the mxunit directory is not in
> the application's directory but is available through a Apache
> mapping....not sure if that would be causing the exception.

I wonder if adding an MXUnit CFML mapping would solve it.

Mappings can be strange beasts.

May The Force be with you!

:den

--
Eddie Valiant: You mean you could've taken your hand out of that cuff
at any time?
Roger Rabbit: No, not at any time, only when it was funny

Marc Esher

unread,
Apr 15, 2010, 1:30:09 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 1:20 PM, Marc Esher <marc....@gmail.com> wrote:
> On Thu, Apr 15, 2010 at 1:08 PM, Peter <underad...@gmail.com> wrote:
>> That allowed me to run the unit tests from inside Eclipse, but I was
>> running them from the url. Regardless, I'm still getting the same
>> ColdFusion error. It only happens when I'm trying to call the methods
>> on an ORM object that is a property of an ORM object.
>
> I'm no ORM expert, but it looks to me like your ORM
> object-that-is-a-property simply isn't being loaded.
>
> what happens if you write a scratch CFM page under your app, and try
> to do what you're doing?

ugggg, sorry... I see you already tried that. my bad

Peter

unread,
Apr 15, 2010, 1:36:22 PM4/15/10
to mxunit
Yea, I have a test CFM page...it works perfectly. I only get the error
when calling the service method from inside of my mxunit test. The
object-that-is-a-property is loaded because I was able to dump the
object. The error occurs when trying to call the implicit getters on
the ORM object (object-that-is-a-property).

On Apr 15, 1:20 pm, Marc Esher <marc.es...@gmail.com> wrote:

Marc Esher

unread,
Apr 15, 2010, 1:46:14 PM4/15/10
to mxu...@googlegroups.com
Hmmmm.....

OK, One more debugging thing. Sorry, I can't reproduce this myself
while I'm at work, otherwise I would. So I kind of have to think about
what are the ways I debug this stuff.

Can you go into mxunit and find RemoteFacadeTester.cfm

Open it and replace "mycomponent", "myfunction", and "remoteurl" with
the values for your test component, the test function, and your
remotefacade URL, respectively. The point here isn't to test the
remote url stuff; rather, the point is to see if there's a difference
between running the test component in three different ways. Because
I'm thinking to myself, "what would cause the implicit getters to not
work if the object is indeed loaded?" and the answers I'm honing in on
have to do with the method in which the component is run, i.e. as a
webservice vs. a normal old request/response.

thanks.

marc

Peter

unread,
Apr 15, 2010, 1:49:00 PM4/15/10
to mxunit
Yea, the mapping is there...:(

denstar

unread,
Apr 15, 2010, 2:03:41 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 11:08 AM, Peter wrote:
> That allowed me to run the unit tests from inside Eclipse, but I was
> running them from the url. Regardless, I'm still getting the same
> ColdFusion error. It only happens when I'm trying to call the methods
> on an ORM object that is a property of an ORM object.

Are you using your custom remoteFacade when you're hitting the URL, or
the old MXUnit one you were probably using to begin with?

It seems like an Application.cfc type deal going on, neh?

:Den

--
Jessica Rabbit: Roger, darling. I want you to know I love you. I've
loved you more than any woman's ever loved a rabbit.

Marc Esher

unread,
Apr 15, 2010, 2:12:35 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 2:03 PM, denstar <vallia...@gmail.com> wrote:
> On Thu, Apr 15, 2010 at 11:08 AM, Peter wrote:
>> That allowed me to run the unit tests from inside Eclipse, but I was
>> running them from the url. Regardless, I'm still getting the same
>> ColdFusion error. It only happens when I'm trying to call the methods
>> on an ORM object that is a property of an ORM object.
>
> Are you using your custom remoteFacade when you're hitting the URL, or
> the old MXUnit one you were probably using to begin with?
>
> It seems like an Application.cfc type deal going on, neh?

Doesn't sound like it to me, Denny. If that were the case, his
original ORM object wouldn't load at all. The problem is in the
composed ORM object


>
> :Den
>
> --
> Jessica Rabbit: Roger, darling. I want you to know I love you. I've
> loved you more than any woman's ever loved a rabbit.
>

denstar

unread,
Apr 15, 2010, 2:50:32 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 12:12 PM, Marc Esher wrote:
> On Thu, Apr 15, 2010 at 2:03 PM, denstar wrote:
...

>> It seems like an Application.cfc type deal going on, neh?
>
> Doesn't sound like it to me, Denny. If that were the case, his
> original ORM object wouldn't load at all. The problem is in the
> composed ORM object

If the original object was loaded, wouldn't it NOT be a string? :

Exception Type: Expression | Message: Element oPropertyThatIsAnObject
is undefined in a Java object of type class [Ljava.lang.String;. |
Detail: | (error code: ) |

Seems like a classic deal of when you /think/ you are getting back
something, but really it's empty.

Or perhaps a scoping deal. The "local" scope is sorta funky now, neh?

Or maybe the ORM session is funky?

I'm playing with Railo's ORM stuff now, and I've got CF9 in my CI
deal, so if Peter wants to write up a test case, I can take it for a
spin and see...

:denny

--
Eddie Valiant: Freeway? What the hell's a freeway?
Judge Doom: Eight lanes of shimmering cement running from here to
Pasadena. Smooth, safe, fast. Traffic jams will be a thing of the past

Peter

unread,
Apr 15, 2010, 3:03:03 PM4/15/10
to mxunit
I tried your debugging suggestion and was met with the following
results:

running test directly - ORM is not enabled for the current application
running test through test suite - ORM is not enabled for the current
application
running test through remote facade - the original error I have been
receiving

On Apr 15, 2:12 pm, Marc Esher <marc.es...@gmail.com> wrote:

Marc Esher

unread,
Apr 15, 2010, 3:05:04 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 3:03 PM, Peter <underad...@gmail.com> wrote:
> I tried your debugging suggestion and was met with the following
> results:
>
> running test directly - ORM is not enabled for the current application
> running test through test suite - ORM is not enabled for the current
> application
> running test through remote facade - the original error I have been
> receiving


ah, sorry, missed a step: copy that file and run it under your
application... that's why you're getting the first two errors.

Peter

unread,
Apr 15, 2010, 3:17:48 PM4/15/10
to mxunit
denny-
I was thinking that, but I have a writeDump(property-that-is-an-
object);abort; right before the three lines that is causing the
exception, and it is in fact an object. For whatever reason, once I
try calling the gets on that ORM objects properties I get the error.
I'll provide a sample ORM component...not sure if that will be
helpful.

component persistent="true" table="Item" {
property name="id" column="id" fieldtype="id" generator="native"
setter="false";
property name="description" column="description";
property name="sortOrder" column="sortOrder";
property name="item2" fieldtype="many-to-one" inverse="true"
cfc="Item2" fkcolumn="item2Id";

public CompItem function toLTO(){
local.oCompItem = createObject("component","CompItem").init();
local.oCompItem.itemId = getId();
local.oCompItem.description = getDescription();
local.oCompItem.sortOrder = getSortOrder();
local.oItem2 = getItem2();
//writeDump(local.oItem2);abort;
local.oCompItem.item2Id = local.oItem2.getId();
local.oCompItem.item2Description = local.oItem2.getDescription();
local.oCompItem.item2SortOrder =local.oItem2.getSortOrder();

return local.oCompItem;

Peter

unread,
Apr 15, 2010, 3:20:43 PM4/15/10
to mxunit
Marc-
No problem. All three throw the original error.

On Apr 15, 3:05 pm, Marc Esher <marc.es...@gmail.com> wrote:

denstar

unread,
Apr 15, 2010, 3:36:25 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 1:17 PM, Peter wrote:
> denny-
> I was thinking that, but I have a writeDump(property-that-is-an-
> object);abort; right before the three lines that is causing the
> exception, and it is in fact an object. For whatever reason, once I
> try calling the gets on that ORM objects properties I get the error.

What happens when you do the dump further down?

local.oPropertyThatIsAnObject = getProp5();
//writeDump(local.oPropertyThatIsAnObject);abort; - good

here...havethe right object


//commenting out the next 3 lines will stop the exception when running
the mxunit test
local.oSomeNewObject.prop5 = local.oPropertyThatIsAnObject.getProp5();

writeDump(local.oPropertyThatIsAnObject.getProp5());
writeDump(local.oSomeNewObject);abort;

A step debugger would be handy here, I reckon. :)

> I'll provide a sample ORM component...not sure if that will be
> helpful.

I was hoping for a ready-made example zip. :)

It's enough tho. I'll work this into what I'm doing with the ORM
stuff and see what happens. Prolly won't have any results for a
whiles tho.

:denny

--
Angelo: Hey, I seen a rabbit.
[Roger gasps]
Eddie Valiant: Ya see?
Judge Doom: Where?
Angelo: He's right here in the bar.
[puts his arm around Harvey the Invisible Rabbit]
Angelo: Say hello... Harvey.
[the whole bar erupts in laughter]
Roger Rabbit: I told you so.

Peter

unread,
Apr 15, 2010, 4:02:19 PM4/15/10
to mxunit
Looking into more, it turned out to be an ORM problem. The
relationship on the ORM object that was throwing the error did not
have a bidirectional relationship setup in ORM, so with my current
implementation, I need to set the value of item2 in item. Thanks for
all the help with this. Sorry, for wasting everyone's time.

Marc Esher

unread,
Apr 15, 2010, 4:10:18 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 4:02 PM, Peter <underad...@gmail.com> wrote:
> Looking into more, it turned out to be an ORM problem. The
> relationship on the ORM object that was throwing the error did not
> have a bidirectional relationship setup in ORM, so with my current
> implementation, I need to set the value of item2 in item. Thanks for
> all the help with this. Sorry, for wasting everyone's  time.

But how is it possible that it worked in the simple cfm file but not
mxunit? that's what I don't understand.

Marc

Peter

unread,
Apr 15, 2010, 4:25:13 PM4/15/10
to mxunit
Cause my test file loaded an item1 that had item2 saved to it. The
mxunit test was loading a new item1 which didn't have item2 saved. So
when I did an add of item1 to item2(which is what my service call was
doing), there was no bidirectional relationship to set item2 to item1.
I'm sure I did a poor job of explaining that.

On Apr 15, 4:10 pm, Marc Esher <marc.es...@gmail.com> wrote:

denstar

unread,
Apr 15, 2010, 4:43:32 PM4/15/10
to mxu...@googlegroups.com
On Thu, Apr 15, 2010 at 2:02 PM, Peter wrote:
> Looking into more, it turned out to be an ORM problem. The
> relationship on the ORM object that was throwing the error did not
> have a bidirectional relationship setup in ORM, so with my current
> implementation, I need to set the value of item2 in item. Thanks for
> all the help with this. Sorry, for wasting everyone's  time.

Woohoo!

No need to apologize, BTW, that's what the list is here for.

There's just going to be more ORM related stuff in the future, so us
getting hip to troubleshooting it is probably not time wasted. :)

:Den

--
Eddie Valiant: One too many refrigerators dropped on his head?
R.K. Maroon: Nah, he's a toon. You can drop anything you want on his
head, he'll shake it off. But break his heart, goes to pieces just
like you and me.

Reply all
Reply to author
Forward
0 new messages