Trying to create a user with following code. ( Changed key token username, passwords for privacy reasons)
But I get following exception. I am using the App42_JAVA_SDK_2.1 JAR file.
Can some one please help .....!!!!! Thanks in advance...
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
at com.shephertz.app42.paas.sdk.java.user.UserService.createUser(UserService.java:89)
at GetData.createUser(GetData.java:39)
at GetData.main(GetData.java:17)
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
import com.shephertz.app42.paas.sdk.java.App42BadParameterException;
import com.shephertz.app42.paas.sdk.java.App42Exception;
import com.shephertz.app42.paas.sdk.java.App42SecurityException;
import com.shephertz.app42.paas.sdk.java.ServiceAPI;
import com.shephertz.app42.paas.sdk.java.user.User;
import com.shephertz.app42.paas.sdk.java.user.UserService;
public class GetData {
/**
* Main Method To Create App42 User on Cloud
* @param args
*/
public static void main(String[] args) {
createUser();
}
/**
* Test Method for creating the User in App42 Cloud.
*/
public static void createUser() {
// initialize
ServiceAPI api = new ServiceAPI("XXX","YYY);
//api.setBaseURL("YOUR_API_SERVER_URL");
// Build User Service
UserService userService = api.buildUserService();
// create User
String userName = "user_xxxx";
String pwd = "YYYYYY";
String emailId = "userxxxx@gmail.com";
try {
User user = userService.createUser(userName, pwd, emailId);
} catch(App42Exception exception) {
int appErrorCode = exception.getAppErrorCode();
int httpErrorCode = exception.getHttpErrorCode();
if(appErrorCode == 2001){
// Handle here for Bad Request
// The request parameters are invalid.
// Username 'Nick' already exists.
} else if(appErrorCode == 2005){
// Handle here for Bad Request
// The request parameters are invalid.
// User with emailId 'nick@shephertz.co.in' already exists.)
} else if(appErrorCode == 1401){
// handle here for Client is not authorized
}else if(appErrorCode == 1500){
// handle here for Internal Server Error
}
String jsonText = exception.getMessage();
}
}
}