Topic: Java Add User
Greetings
I'm running the Java API and working with the example code.
I'm attaching the code.
I can get a list of units, but when I try to add a user (or a unit), I get the following:
Session ID:01bf9f9a1c999513bdf3d88d1b7ef5a6
Adding USER:
com.wialon.item.User@15317ed
Unknown error
java.lang.NullPointerException
at UnitsSearchExample$3.onFailure(UnitsSearchExample.java:780)
at com.wialon.remote.handlers.ResponseHandler.onFailure(ResponseHandler.java:47)
at com.wialon.remote.RemoteHttpClient$RemoteCallback.processStringAnswer(RemoteHttpClient.java:247)
at com.wialon.remote.RemoteHttpClient$RemoteCallback.done(RemoteHttpClient.java:229)
at com.wialon.remote.ApacheSdkHttpClient$HttpRequest.run(ApacheSdkHttpClient.java:190)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Unknown error
java.lang.NullPointerException
at UnitsSearchExample$3.onFailure(UnitsSearchExample.java:780)
at com.wialon.remote.handlers.ResponseHandler.onFailure(ResponseHandler.java:47)
at com.wialon.remote.RemoteHttpClient$RemoteCallback.processStringAnswer(RemoteHttpClient.java:247)
at com.wialon.remote.RemoteHttpClient$RemoteCallback.done(RemoteHttpClient.java:229)
at com.wialon.remote.ApacheSdkHttpClient$HttpRequest.run(ApacheSdkHttpClient.java:190)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Logout successfully
---------------------------------------------------
Here's the code stub:
session.createUser(session.getCurrUser(), "AddTest", "foobar", (long) 0x0001, new SearchResponseHandler() {
@Override
public void onSuccessSearch(Item... items) {
super.onSuccessSearch(items);
// Search succeed
System.out.println("Create User was successful");
// printUnitsNames(items);
logout();
}
@Override
public void onFailure(int errorCode, Throwable throwableError) {
super.onFailure(errorCode, throwableError);
// search item failed, print error
System.out.println(Errors.getErrorText(errorCode));
throwableError.printStackTrace();
logout();
}
});