Initialize proxy object: given object cannot be NULL

I passed an IMendixIdentifier and an IContext to a proxy object type's static Initialize method and the proxy's constructor threw an exception telling me that the "given object cannot be null". This is the code: IMendixIdentifier previousEventId = auditableObject.<IMendixIdentifier>getValue (Auditable.MemberNames.Auditable_AuditLatest.toString()); if (previousEventId == null) { // avoid the issue } else { auditableObject.setValue (Auditable.MemberNames.Auditable_AuditPrevious.toString(), previousEventId); AuditEvent oldEvent = AuditEvent.initialize (context, previousEventId); Why should this happen? The IMendixIdentifier is not null and its integer value is positive. If the object pointed to by Auditable_AuditLatest had been deleted, would not previousEventId also be null? Here's the top of the stack trace: Caused by: java.lang.IllegalArgumentException: The given object cannot be null. at audit.proxies.AuditEvent.<init>( at audit.proxies.AuditEvent.initialize( at audit.proxies.AuditEvent.initialize( at pipsandsubbies.actions.writeAuditDescriptorString
1 answers

If you initialize a proxy with a MendixIdentifier, the initialize method will call Core.retrieveId() to retrieve the object for the given identifier. In your situation Core.retrieveId() doesn't return an object, so probably the object doesn't exist anymore.

You can inspect the proxy code to see all the details.