Error: Keypool ran out, please call keypoolrefill first
Unlock your wallet (using walletpassphrase) and run keypoolrefill as the error message says. generate and setgenerate requires keys from the wallet, and if the keypool is empty, they won't work.