You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using azkaban 3 in my project to manage jobs, I am using ajax api to operate all steps for flows/jobs, I have achieved all steps including creating project, deleting project, schedule flow and executing flows etc with ajax api using java, but now I have a problem when uploading the zip to azkaban, below are the issue, sincerely hope you can help have a look into this, Thanks very much.
Issue desc: when invoke the uploadZip method it promoted me below error, but when I create project or execute flow with the same way it is fine:
Login error222. Need username and password
net.sf.json.JSONException: A JSONObject text must begin with '{' at character 1 of Login error222. Need username and password
at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:499)
at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:972)
at net.sf.json.JSONObject._fromString(JSONObject.java:1201)
at net.sf.json.JSONObject.fromObject(JSONObject.java:165)
at net.sf.json.JSONObject.fromObject(JSONObject.java:134)
at com.td.rd.dmsys.jobs.scheduler.AjaxHelper.newPost(AjaxHelper.java:166)
at com.td.rd.dmsys.jobs.scheduler.AzkabanAPI.uploadZip(AzkabanAPI.java:97)
at com.td.rd.dmsys.jobs.controller.AzkabanMain.main(AzkabanMain.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Exception in thread "main" java.lang.NullPointerException
at com.td.rd.dmsys.jobs.scheduler.AzkabanAPI.uploadZip(AzkabanAPI.java:104)
at com.td.rd.dmsys.jobs.controller.AzkabanMain.main(AzkabanMain.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
uploadZip method as below:
public long uploadZip(String zipPath, String proName){
if(sessionId != null){
String uploadZipStr = "session.id=" + sessionId
After trial and error, I can upload the file to the project finally.
I don't know if the document gets something wrong or not, since I make it works by comparing my request with the raw request in azkaban web and reading the source code.
So, there is something which is different from / does not mention in the document in my solution.
The URL is /manger instead of /manager?ajax=upload
Add field "action" with value "upload" in the body
Add boundary in the Context-Type in request header
Add boundary to separate each multipart parameters
I also have a piece of code which uses Apache HttpClient library to make the request and I am using Groovy.
I am using azkaban 3 in my project to manage jobs, I am using ajax api to operate all steps for flows/jobs, I have achieved all steps including creating project, deleting project, schedule flow and executing flows etc with ajax api using java, but now I have a problem when uploading the zip to azkaban, below are the issue, sincerely hope you can help have a look into this, Thanks very much.
Issue desc: when invoke the uploadZip method it promoted me below error, but when I create project or execute flow with the same way it is fine:
Login error222. Need username and password
net.sf.json.JSONException: A JSONObject text must begin with '{' at character 1 of Login error222. Need username and password
at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:499)
at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:972)
at net.sf.json.JSONObject._fromString(JSONObject.java:1201)
at net.sf.json.JSONObject.fromObject(JSONObject.java:165)
at net.sf.json.JSONObject.fromObject(JSONObject.java:134)
at com.td.rd.dmsys.jobs.scheduler.AjaxHelper.newPost(AjaxHelper.java:166)
at com.td.rd.dmsys.jobs.scheduler.AzkabanAPI.uploadZip(AzkabanAPI.java:97)
at com.td.rd.dmsys.jobs.controller.AzkabanMain.main(AzkabanMain.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Exception in thread "main" java.lang.NullPointerException
at com.td.rd.dmsys.jobs.scheduler.AzkabanAPI.uploadZip(AzkabanAPI.java:104)
at com.td.rd.dmsys.jobs.controller.AzkabanMain.main(AzkabanMain.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
uploadZip method as below:
public long uploadZip(String zipPath, String proName){
if(sessionId != null){
String uploadZipStr = "session.id=" + sessionId
JSONObject uploadJson = null;
try {
uploadJson = AjaxHelper.newPost(url + "/manager", uploadZipStr, null, "multipart/mixed");
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("Upload zip submitted failed, pls check...");
e.printStackTrace();
}
return Long.parseLong(uploadJson.getString("projectId"));
}
return -1L;
}
newPost method as below:
public static JSONObject newPost(String url, String xmlStr, String cookie, String contentType) {
try {
initHttpsURLConnection();
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jsonObj = null;
HttpsURLConnection urlCon = null;
try {
urlCon = (HttpsURLConnection) (new URL(url)).openConnection();
urlCon.setDoInput(true);
urlCon.setDoOutput(true);
urlCon.setRequestMethod("POST");
if(contentType == null || contentType.equals("")) {
urlCon.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
} else {
urlCon.setRequestProperty("Content-Type", contentType + "; boundary=" + "--aifudao7816510d1hq");
}
The text was updated successfully, but these errors were encountered: