I am trying to assign a role to a user in my signup function.
by using below code:
try {
role.save(new CloudRoleCallback() {
@Override
public void done(CloudRole cloudRole, CloudException t) throws CloudException {
if(cloudRole != null){
System.out.println("Adding user role"+ ""+ cloudRole.getRoleName());
userObj.addToRole(role, new CloudUserCallback() {
@Override
public void done(CloudUser cloudUser, CloudException e) throws CloudException {
if(cloudUser != null){
System.out.println("role in role added successfully");
}
if(e != null){
e.printStackTrace();
}
}
});
}
if( t != null){
t.printStackTrace();
}
}
});
}
userObj.signUp(new CloudUserCallback() {
@Override
public void done(CloudUser cloudUser, CloudException e) throws CloudException {
if (cloudUser != null) {
onSignupSuccess();
}
if (e != null) {
e.printStackTrace();
error = e.getMessage();
error = error.substring(error.indexOf(""));
onSignupFailed();
progressDialog.dismiss();
}
}
});
When i try to run above code i am getting following error.
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2 Process: info, PID: 967 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at java.io.StringReader.(StringReader.java:47) at io.cloudboost.json.JSONTokener.(JSONTokener.java:85) at io.cloudboost.json.JSONObject.(JSONObject.java:324) at io.cloudboost.CloudUser.addToRole(CloudUser.java:317) at com.rakesh_kr.msrit_info.SignUp$signupClass$1.done(SignUp.java:149) at io.cloudboost.CloudRole.save(CloudRole.java:83) at com.rakesh_kr.msrit_info.SignUp$signupClass.doInBackground(SignUp.java:144) at com.rakesh_kr.msrit_info.SignUp$signupClass.doInBackground(SignUp.java:126) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)