Debugging SonarQube Server

1,001 views
Skip to first unread message

anand sudhan

unread,
Sep 26, 2016, 12:01:10 PM9/26/16
to SonarQube
Hi Folks,

I wish to debug the Sonarqube server (not the language plugin). My desire to do so  comes from the fact that 
I have custom plugins that I have implemented, and  I need to understand how certain reflections of RuleProperty happens in the plugin.

I also would like to debug Sonar-Runner .jar, if thats possible.

Thanks,
Anand

Teryk Bellahsene

unread,
Sep 27, 2016, 8:07:09 AM9/27/16
to SonarQube
Hello,

To debug SonarQube add the following line to your conf/sonar.properties file: sonar.web.javaAdditionalOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
Then in your IDE or whatever attach to the server.

HTH,

Teryk
Message has been deleted

anand sudhan

unread,
Sep 27, 2016, 5:15:44 PM9/27/16
to SonarQube
Hi Teryk,

Thanks a bunch - I am able to debug very nicely now.
I am currently starting the server and attaching to the code via IDE. But I feel like I am searching for a needle in a haystack!

Would the debugging session last throughout the running of the Server or does it only last for the startup phase of the server ?

Could I also debug sonar-runner 2.4(aka scanner) via this option?

Thanks!
-Anand

Simon Brandhof

unread,
Sep 28, 2016, 2:48:07 AM9/28/16
to anand sudhan, SonarQube
You can put breakpoints at any place, even in code executed by a HTTP request.
So to answer your question : not only startup phase but during all lifecycle of web server.

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/c0cf0b77-b341-41fb-825e-880774c55d70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof

Simon Brandhof

unread,
Sep 28, 2016, 2:49:19 AM9/28/16
to anand sudhan, SonarQube
You can find more details about debugging at http://docs.sonarqube.org/display/DEV/Build+Plugin
Message has been deleted

anand sudhan

unread,
Nov 14, 2016, 3:03:59 PM11/14/16
to SonarQube, anand.su...@gmail.com
Hi Folks,

There are (atleast) 3 processes, when we start the SQ server. So when we try to debug the SQ server after setting the sonar.web.javaAdditionalOpt property in sonar.conf file (as mentioned above posts,
am I am now  guaranteed to be able to debug all the processes?

I am unable to hit many breakpoints in the SQ server. I actually am able print log messages that i inserted in the console but still break points on those messages dont get executed.
I use Eclipse Neon IDE.  I got some success by adding more source files/dirs to Debug congfiguration Source tab.

I am not sure if I am missing something?

TIA!
Anand

Simon Brandhof

unread,
Nov 14, 2016, 3:18:21 PM11/14/16
to anand sudhan, SonarQube
You should use sonar.web.javaOpts to debug web server and sonar.ce.javaOpts to debug Compute Engine (the process that executes "background tasks" like integration of analysis reports).
On which classes do you add breakpoints ?

Regards


For more options, visit https://groups.google.com/d/optout.

anand sudhan

unread,
Nov 14, 2016, 3:35:39 PM11/14/16
to SonarQube, anand.su...@gmail.com
Hi Simon,

Basically the end goal is to see if I can get to IssuesReportBuilder class in the debug mode - but that is not happening.

I have Break Points in ExtensionInstaller class (inside sonar-scanner-engine).

Should I enable both sonar.web.javaOpts and sonar.ce.javaOpts at 2 different ports? 

Thanks for swift response!
-Anand

Simon Brandhof

unread,
Nov 14, 2016, 3:42:48 PM11/14/16
to anand sudhan, SonarQube
org.sonar.scanner.scan.report.IssuesReportBuilder is a class of scanner but not server !


For more options, visit https://groups.google.com/d/optout.

anand sudhan

unread,
Nov 14, 2016, 3:53:31 PM11/14/16
to SonarQube, anand.su...@gmail.com
Simon,

The file is moved to sonar-scanner-engine project @ org.sonar.batch.scan.report.IssuesReportBuilder in SQ 5.6.3 LTS version.
So basically there is no standalone Issues Report plugin anymore and that has been baked in to SQ.

I also couldn't find IssuesReportBuilder in github sonarsource CLI repo.

Thanks,
Anand

Simon Brandhof

unread,
Nov 14, 2016, 4:00:11 PM11/14/16
to anand sudhan, SonarQube
Exact. The module sonar-scanner-engine is part of SonarQube and is executed at runtime in a scanner process.


For more options, visit https://groups.google.com/d/optout.
Message has been deleted

anand sudhan

unread,
Nov 14, 2016, 5:27:59 PM11/14/16
to SonarQube, anand.su...@gmail.com
Sorry I forgot to reply all : so pasting the rest of our conversation here for the benefit of all!

====================================================================

That's brilliant.

Simon you have made things very clear for me now. :)

 

Thanks n Regards,

Anand 

 

On Mon, Nov 14, 2016 at 5:18 PM, Simon wrote:

As sonar-scanner-cli-* support multiple versions of SonarQube, the trick is that sonar-scanner-engine.jar is distributed within the server. It is downloaded then executed by sonar-sonar-cli at runtime. It allows to have sonar-scanner-cli executing a version of sonar-scanner-engine that is always up-to-date and synchronised with server.

To answer your question, no code from sonar-scanner-cli nor sonar-scanner-engine is executed on server.

 

On Mon, 14 Nov 2016 at 22:59 anand  wrote:

Thanks very much, Simon! this worked!

 

I am very curious as to know :

 How the sonar-scanner-cli-xx jar at the client side and the sonar-scanner engine inside the server are connected?

 Does the sonar-scanner-cli-xx jar start a process that executes the code inside the server?

 

I thought sonar-scanner downloaded the plugins into the local cache from the SQ server and after that it pretty much gave up.

 

Regards,

Anand

Reply all
Reply to author
Forward
0 new messages