The getAppId() method from the Key class does the following:
public String getAppId() {
return appIdNamespace.getAppId();
}
It is very likely that in your case, the appIdNamespace is null, which is causing the error. Make sure that your appUser has been retrieved from the datastore so that your groups keys are properly set. If these keys are generated in your code, use the KeyFactory.createKey method, which will generate the appIdNamespace for you.