jrjc JSONObject["type"] not found Edited

(Posted this under discussion, but it was marked as spam, so trying here)

I am trying to set up Hygieia dashboard and while setting up the jira-collector (which has jira-rest-java-client-core v3.0.0 as a dependency) I came across the following error:

Caused by: org.codehaus.jettison.json.JSONException: JSONObject["type"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:360) ~[jettison-1.1.jar!/:1.1]
at org.codehaus.jettison.json.JSONObject.getString(JSONObject.java:487) ~[jettison-1.1.jar!/:1.1]
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parseSchema(IssueJsonParser.java:344) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parseFields(IssueJsonParser.java:309) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:223) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:88) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.json.GenericJsonArrayParser.parse(GenericJsonArrayParser.java:39) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.json.SearchResultJsonParser.parse(SearchResultJsonParser.java:40) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.json.SearchResultJsonParser.parse(SearchResultJsonParser.java:27) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$1.handle(AbstractAsynchronousRestClient.java:145) ~[jira-rest-java-client-core-3.0.0.jar!/:na]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:186) ~[jira-rest-java-client-core-3.0.0.jar!/:na] 

The error thrown is from:


and that line looks like:

(line 343) JSONObject fieldDefinition = json.getJSONObject(fieldId);
(line 344) res.put(fieldId, fieldDefinition.getString("type"));  <<< res is a map returned by this method

The json object parsed by IssueJsonParser.parseSchema causing the exception looks like:


which does not contain the field "type".

As IssueJsonParser.parseSchema is a private method only called by IssueJsonParser.parseFields, and that method is only concerned with values of type, "key":

res.add(new IssueField(key, namesMap.get(key), typesMap.get("key"), value != JSONObject.NULL ? value : null));

should IssueJsonParser.parseSchema check for "type" field prior to adding to the map, i.e.:

(line 344 becomes)
if (fieldDefinition.has("type")) {
res.put(fieldId, fieldDefinition.getString("type"));

or should com.onresolve.jira.groovy.groovyrunner:scripted-field be required to contain a "type" field?

Currently I am implementing the if-statement, but that requires me to maintain my own version of jrjc which I would rather avoid doing. I am new to Jira and jrjc so I was hoping start a discussion on whether adding the if-statement is most appropriate or if adding the "type" field is a better option. If the latter, how would one go about adding this field? Any help would be much appreciated, thanks.

0 answers

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 14 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

41 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you