Skip to main content
MSO_Simon
Participant
April 19, 2013
Question

NULL POINTER error when using ObjectLoad(ObjectSave())

  • April 19, 2013
  • 1 reply
  • 503 views

Hi there.  I've already posted this up on stackoverflow, but thought it might be worth posting here too in case anyone here had some information.  The SO link is http://stackoverflow.com/questions/16103089/null-pointer-error-when-using-objectloadobjectsave


I've been having a problem with CF9 and NULL POINTER errors that do not appear to be an issue within Railo. I created a simple CFC and associated mxunit unit test to confirm this with.

On Railo (4.0.4) both unit tests pass. On Coldfusion (9.0.1), the unit test getMetaDataBeforeMethodInvocation fails with NULL POINTER error on the GetMetaData call.

At present I can only surmise that CF9 does not have access to the full metadata following ObjectLoad until a method within that component is called. Is anyone able to shed more light on this problem, and/or offer a better solution than to ensure that a method within the object is called prior to doing getMetaData?

Here is the CFC

// NullError.cfc
component
{
   
public NullError function init() {
        variables
.uuid = CreateUUID();
       
return this;
   
}
   
public string function getUUID() {
       
return uuid;
   
}
}

and associated unit test

// NullErrorTest.cfc
component
extends='mxunit.framework.TestCase' {
   
private any function setupTheTests() {
       
var o = new NullError();
        debug
(o.getUUID());
       
// Dump meta data
        debug
(GetMetaData(o));
       
// Save and load it, and return
       
return ObjectLoad(ObjectSave(o));
   
}

   
public void function getMetaDataBeforeMethodInvocation() {
       
var o = setupTheTests();
       
// Get meta data, and then get uuid, expecting this to ERROR (NULL POINTER)
        debug
(GetMetaData(o)); // CF FAILS HERE, RAILO DOES NOT
        debug
(o.getUUID());
   
}

   
public void function getMetaDataAfterMethodInvocation() {
       
var o = setupTheTests();
       
// Get uuid, and then get meta data, expecting this to be ok
        debug
(o.getUUID());
        debug
(GetMetaData(o));
   
}
}

This topic has been closed for replies.

1 reply

MSO_Simon
MSO_SimonAuthor
Participant
April 22, 2013