WebObjects 5.0: Key-Value Coding Access Throws NSKeyValueCoding$UnknownKeyException

Java package access variables cannot be accessed using key-value coding (NSKeyValueCoding) unless Java code changes are made.
Symptom

When WebObjects tries to get or set a Java package access variable with no accessor methods using key-value coding, a NSKeyValueCoding$UnknownKeyException is thrown. This can occur after the conversion to Java of an Objective-C class that does not implement accessor methods for all instance variables.


Solution

To access Java package access variables using key-value coding, one of the following must be done in order of preference:


Implementing KeyValueCodingProtectedAccessor is the least preferred solution because it imposes a significant performance penalty, so this should be considered a temporary solution until one of the more preferred solutions has been implemented.

For additional details, see the NSKeyValueCoding.ValueAccessor class description at Apple's Developer Web site.

http://developer.apple.com/techpubs/webobjects/FoundationRef/Java/Classes/NSKVCValAcc.html

Published Date: Feb 18, 2012