Sonar Server in Debug Modus - Do not stop at Breakpoint - remote-debugging

For the development of my own sonar plugin i want to be able to debug.
after quite a while I found out how to run the sonarqube server in debug mode. Therefore I followed the instruction of the following website. enter link description here
When I started the server in debug modus an connect eclipse by using the debug configuration, the server starts but it do not not stop at the breakpoints that I have been set. I have set breakpoints to extension point (classes) like the one which extends the SonarPlugin class or the one which extends the RuleRepository class. The logs of these classes are part of the server log file, so I'm pretty sure that this classes are executed. Nevertheless it doesn't stop at the breakpoints.
Anyone ideas whats the problem?

The server runs as three process - a parent application, the web server and a search server. Plugins are loaded into the web server so you need to start this with debug arguments. The options for this seem to have changed and are not yet reflected in the documentation. To debug the web server put:
sonar.web.javaAdditionalOpts=-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address=9001
into your sonar.peroperties file and start sonar using the StartSonar script. This will launch all three applications, but with the web server suspended. Attach your debugger to port 9001 and you should find your plugin main class and rules definition breakpoints are hit.

Related

How to run multiple instances of console app with VS2019?

I am following networking tutorial series and I need to run both Server and Client projects. When I click ServerProject->Debug->Start New Instance everything is fine, but the option becomes unavailable for ClientProject while Server is running. How can I enable this option and run them both? There is also a third project with winsock stuff set as Startup Project and both Server and Client depend on it.

How to debug production setup for java?

I am currently working on a web-app. Basically deployed as .war file on production enviornment. The server is tomcat7.
Since the code is written in java. There are ocassional log statements on server side.
If I am given an issue to resolve, I do not have a duplicate data-set / subset of data , as like production. So the problem that I face, is replicating the scenario , in case of testing.
Since this is production enviornment, attaching a remote debugger , would mean that the functionality would halt/ when I am stepping through break points, So I am not able to debug remotely.
so, currently, the only visiblity I have with regards to the behavior of the system is, The code base, and the log statements in code.
How Do you suggest I debug the server side code without restarting the application.
Any insight in this matter would be appreciated.
Thank you.
As you cannot attach a remote debugger in production there is no other way to debug your code other than the logs and matching the line number in your code.
1) You could ask for the sample scenarios which caused the issue and try to reproduce it in your development environment with debugger attached.
2) You could fine tune the log level to DEBUG mode to catch more useful logs.
3) Check various logs like application log, server log, access log, etc
3) You could ask for the test data which has caused the issue and try the same in dev environment.
Ideally you need a mock production environment with minimum mock data so that you could attach your debugger and step into the code.
Otherwise it would be time consuming and impossible to reproduce the production issues.

Remote debug WebLogic cluster

I need to remotely debug a Java EE application running on a WebLogic 10.3.5 cluster. It is important that I debug it whilst clustered, not running on a single box.
I have read docs that state you can either modify the Java Options in the start script or the debug flag in the domain config, however what I do not understand is how you know which server to connect to when clustered.
My cluster is configured for round robin load balancing so I have no way of knowing which server to connect my debugger to.
Is it possible to connect the remote debugger to the cluster rather than a single server?
It would seem there's no domain or cluster level connection available. One must open a new debugger connection to each server.
It just wasn't obvious in my IDE that clicking debug more than once would open multiple debugger connections.
You could try something like this,
Create Debug configuration with Host and Port number of the Admin Server which manages the cluster servers.
Try debug on admin server.

Windows event log service holding executable file handle

I have a service application that on startup and shutdown logs an event log record.
I rebuild the application frequently and also then the executable on the host machine. And here is the problem, after my service shutdown the Windows Eventlog service (not the event log viewer) is holding an open handle to the executable so I cant update it.
I have the event log messages embedded in the executable, i could move it out but then I just move the update problem to another file.
I've double checked and I have paired ::RegisterEventSource/::DeregisterEventSource correctly.
Anyone encountered this problem ?
I've also run into this issue, so just adding some of my experiences.
I have a Windows 2008 Service system (have not seen this on 2003 Server), and when I stop my service, and instance of svchost.exe loads the service executable (visible using vmmap.exe or Process Hacker) preventing it from being deleted/overwritten during uninstall/install. The instance of svchost.exe is running the DHCP Client (Dhcp), TCP/IP NetBIOS Helper (lmhosts), and Windows Event Log (EventLog) services.
In our case, we have created a registry entry to make our service executable an event source. (though I'm unsure exactly why we are doing this, or whether we should be doing this).
Empirically, if I remove that registry entry before stopping the service, the executable is not loaded by svchost.exe and all is fine. If the service has already been stopped and executable loaded by svchost.exe, restarting the Event Log service (or killing the process) also frees up the executable.
I'm guessing our service is not well-behaved (perhaps a side effect of being a 32-bit process on 64-bit OS?) or correctly installed, but haven't isolated the issue yet.
Update: It appears this issue is only happening on HP systems (and not Dell or IBM) which is curious. There are HP-specific management components installed, so perhaps one of them is altering the behavior somehow?
I've also run into this issue. In my case, nxlog service reading logs. Simply stop nxlog service before replace event source file.
I think it is probably the event log viewer. Close the viewer and you'll be fine.

How remote debugging is implemented in general

I have been using remote debugging from JDeveloper to Weblogic server for quite sometime and found it's very useful. But I am interested in understanding how remote debugging is implemented technically.
When I make any java code change and rebuild the class in jdeveloper on a remote machine from where I am debugging the server, the code changes are automatically picked up the server. How does this happen? Does the tool send the compiled java class on the network to server?
Can any one please share any documents / links explaining the technicalities of remote debugging.
Thanks & Regards,
Harish
Not sure if you're asking about remote debugging in general, or for the particular tools you're describing.
I don't know much about Java/jdeveloper, but in general remote debugging works as follows:
On the target machine, a special server process hooks into the executable you want to debug, just like a debugger would when running locally. This server doesn't have to know about symbols and source code, just have the executable running. Using system commands it can ask it to stop and examine its memory space.
On the host machine the debugger itself runs and also has a copy of the executable, and of its source code. The debugger communicates with the server on the target machine using some kind of protocol (TCP/IP or maybe serial for embedded devices) and asks it to step, examines certain memory locations it knows about from the debug info in the executable, can show the source code being debugged to the user, etc.
Read, for example, on gdbserver which is probably the most popular remote debugging server out there.
Hope this helps :)