sonar4stash rest api causing exception in Stash

We are getting the following exception in Stash when reviewing a pull request.  This exception began after upgrading SonarQube to 5.3.


2016-01-28 20:00:35,915 ERROR [http-nio-8080-exec-1018] michael_giroux @17KNLFXx1200x12511000x6 msajgq "GET /rest/sonar4stash/1.0/sonarissues HTTP/1.1" c.a.p.r.c.e.j.ThrowableExceptionMapper Uncaught exception thrown by REST service: JSONObject["pages"] not found.
org.json.JSONException: JSONObject["pages"] not found.
at org.json.JSONObject.get( ~[json-20070829-1.jar:na]
at org.json.JSONObject.getInt( ~[json-20070829-1.jar:na]
at$mibex$stash$sonar4stash$sonar$DefaultSonarClient$$toPagingInfo(DefaultSonarClient.scala:134) ~[plugin_1120250090807200834_sonar4stash-1.3.3_1454032655000.jar:n

3 answers

1 accepted


Which version of the plug-in are you using? Please note that version 1.4.0 is not compatible with SonarQube 5.2/5.3. You have to upgrade to plug-in version 1.5.0.

Hope that helps.

Best regards,


Sorry for the out of order replies.  I suspect a configuration issue, but I'm not sure what to change.

we have Jenkins post build step that is generating sonar data, but the pull requests don't link to it. 


see the other two posts that did not link to your question.

At the time of the stack trace, we had 1.3.3. installed.  Misread the comparability matrix.

However, we had tried 1.5.0, and that was giving us issues as well.

Background -- we are building in Jeniins and are using a post build step described in Atlassian wiki. Does this need to be refined for the current configuration (SonarQube 5.3 + sonar4stash 1.5.0)

# --------------------------------------------------------------
# A post-build script to parse the GIT_BRANCH variable into a
# simple branch name suitable for use as a sonar project name.
# Ref: sonar3stash plugin
# --------------------------------------------------------------
echo SONAR_BRANCH=$(printf '%s' $GIT_BRANCH | cut -d'/' -f 2- | sed s/[^0-9a-zA-Z:_.\-]/'_'/g) | tee sonar-branch

With version 1.5.0 installed, I'm seeing this:

2016-01-29 07:56:57,690 WARN [http-nio-8080-exec-1188] michael_giroux @17KNLFXx476x12533224x9 11cu9ts "GET /rest/sonar4stash/1.0/statistics HTTP/1.1" c.m.s.s.s.i.IssuesInPullRequestCollector SONAR:choicehotels.devops:test does not match the determined one from the build files choicehotels:test

and a few others like this:

2016-01-29 07:56:59,485 WARN [http-nio-8080-exec-1195] leon_mattie @17KNLFXx476x12533225x7 1jh80nz "GET /rest/sonar4stash/1.0/statistics HTTP/1.1" c.m.s.s.s.s.SonarStatisticsResource SONAR: 404 failed to retrieve statistics: Not Found
2016-01-29 07:57:01,762 WARN [http-nio-8080-exec-1188] leon_mattie @17KNLFXx477x12533244x7 1jh80nz "GET /rest/sonar4stash/1.0/statistics HTTP/1.1" c.m.s.s.s.s.SonarStatisticsResource SONAR: 404 failed to retriev


Your Jenkins configuration is fine and should work with SonarQube 5.3 as well.

The error message you get means that the SonarQube project key you defined in the repository settings of the plug-in does not match the one from your build files. Has that changed lately? Could you please try to change your project key in the repository settings to "choicehotels:test"?

What kind of build system are you using to trigger SonarQube (Gradle, Maven, SonarRunner)? If changing the project key does not help, you could try to switch to the "compatibility mode" in the plug-in settings which behaves like version 1.3.3.

Thanks for the pointers.  I now have a pull request with stats in the overview and sonar issues flagged in the diff view.

It looks like the update to version 1.5.0 was the root cause.  Other issues came about due to a source change I made trying to dig into this.

FWIW, I did not find anything on the internet describing the error I got from the 1.3.3.version:

ThrowableExceptionMapper Uncaught exception thrown by REST service: JSONObject["pages"] not found.


I might have solved this myself if the plugin logged a warning that a version conflict may exist. Just thinking out loud smile


Again, thanks for the help.

Glad to here that it worked for you!

You're absolutely right. We will log a warning in this case for the next version of the plug-in. I have also added it to our knowledge base (see

Thanks for updating the KB. 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,767 views 1 5
Read article

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