Fixed createResource usage. Realm must always be set by the caller.