Constraint checking failing with NullPointerException