Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

jira rest java client + JSONObject["assignee"] not found

Shradha Singh October 15, 2015

Hi Experts!

I have downloaded JIRA REST JAVA Client zip and have set it up. I have added all required dependencies also.

I am trying to fetch issue details using rest api. Here is the code. Connection is getting established with http://jira. But I am getting following error. I am the assignee of the issue TES-1. 

==========================ERROR==============================================

"Exception in thread "main" net.sf.json.JSONException: JSONObject["assignee"] not found."

=========================CODE================================================

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import net.rcarz.jiraclient.*;

@SuppressWarnings("unused")
public class TestJIRARestClient {

 

/**
* @param args
*/
public static void main(String[] args) {
BasicCredentials creds = new BasicCredentials("user", "password");
JiraClient jira = null;
try {
jira = new JiraClient("http://jira/", creds);
     System.out.println("Connection success JIRA");
} catch (JiraException e) {
     System.out.println("Error in making connection with JIRA");
e.printStackTrace();
}

try {

String includeFields = "summary";
final Issue issue = jira.getIssue("TES-1",includeFields);

System.out.println(issue);

System.out.println(issue.getKey());

} catch (JiraException ex) {

System.err.println(ex.getMessage());

if (ex.getCause() != null)
System.err.println(ex.getCause().getMessage());
}

}

}

=========================================CONSOLE================================

Connection success JIRA
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.BasicClientConnectionManager).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" net.sf.json.JSONException: JSONObject["assignee"] not found.
at net.sf.json.JSONObject.get(JSONObject.java:1449)
at net.sf.json.JSONObject.get(JSONObject.java:1433)
at net.rcarz.jiraclient.Issue.deserialise(Issue.java:649)
at net.rcarz.jiraclient.Issue.<init>(Issue.java:637)
at net.rcarz.jiraclient.Issue.get(Issue.java:1056)
at net.rcarz.jiraclient.JiraClient.getIssue(JiraClient.java:122)
at com.cad.it.jiraclient.TestJIRARestClient.main(TestJIRARestClient.java:31)

 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 15, 2015

Hi Shradha,

I repeat the same to all who ask about JRJC: Throw away jira-rest-java-client-api and do direct calls to JIRA REST API: https://docs.atlassian.com/jira/REST/latest/

jira-rest-java-client-api is just a wrapper around REST API and it's not in sync with the latest JIRA REST API. You can get errors when using it to query recent JIRA versions.

If you still want to go with JRJC you cat try to debug what actually is returned from JIRA. Based on the stacktrace I guess you need to debug/log near net.rcarz.jiraclient.Issue.deserialise.

TAGS
AUG Leaders

Atlassian Community Events