Please put this logic in a separate init() method. Then call it here plus at the end of readFields, after the super.readFields() call. Otherwise, it won't get executed when this expression is used on the server-side, as the server-side uses the empty arg constructor.