Setting up SonarLint for multiple projects / Java timeout problem

  • Operating system: Windows 11 x64
  • SonarLint plugin version: v3.11.0
  • Programming language you’re coding in: JavaScript
  • Is connected mode used: Yes, connected to SonarQube

Hi there! So I’ve been working on getting SonarQube set up for my work’s microapp, both UI and API, and I had luck getting it squared away in Azure DevOps. Now it’s time to move onto SonarLint to get all of the devs on the same page. Visual Studio was a breeze, but VS Code has been…well, a headache, to say the least.

To clarify, we have two different projects within our microapp. Let’s call them project A and Project B, each with their own UI and API. (Only worrying about the UI currently.) I am able to connect to Project A and add binding accordingly. Which is great! Love how quickly it starts pointing out where we need to make changes.

image

However, where we run into problems is when I try to do project binding for project B. Or rather, as soon as I open up Project B in VS Code, we get the “spinning wheel of death” next to SonarQube underneath Sonarlint Connected Mode, followed by the following error message in the output:

Furthermore, instead of a checkmark/blue circle next to “https-sonarqube-xxxxx”, we now see an orange circle, and I’m unable to add any binding. AND when I click on the plus sign to try to bind to the current UI folder, the circle turns white. Then, if I go back to Project A’s folder, we run into the same problem, thereby crippling the entire process. And to clarify: I’ve tried to do A first, and B first; problem happens no matter the order.

I would be happy to send over more information, if needed, but trying to keep any identifying information private if possible.

Thank you so much!

PS: I did try to query search as much as possible, but I didn’t find anything that fit this specific criteria. However, I recognize I may have missed something, and I apologize if that’s the case.

Hello David,

Thanks a lot for reporting this behavior. I was able to reproduce it and have created this ticket for the team to investigate and fix the issue. We will try to tackle it as soon as possible. :spiral_calendar:

In the meantime, the workaround is to wait for a bit (approximately 5-10 seconds) to allow SonarLint to load fully and then expand the SonarQube item. This should allow all configurations to be read in time and display the views properly.

We understand the inconvenience that this bug brings and hope the workaround helps before we apply the fix. :bowing_man:

Best,
Sophio from SonarLint

2 Likes

Hi, Sophio! Thank you so much for taking the time to check this out. Yes, it appears the workaround is successful. I’ll make sure to add this in extra-super-bold for my dev team so they don’t run into the same problem like I did. :smile:

1 Like

Hi, Sophio! Any update on this issue? The workaround was successful at first, but now that I’m actively working on both projects, it appears I’m going to have to re-add the SonarQube connection each time I want to analyze a different project…which is quite annoying.

When the circle goes white and times out (no message in the log), I hit refresh to try to update the bindings, which is when I get:

Error running command SonarLint.UpdateAllBindings: Internal error… This is likely caused by the extension that contributes SonarLint.UpdateAllBindings.

Hello David!

it appears I’m going to have to re-add the SonarQube connection each time I want to analyze a different project

I don’t fully understand why this could be happening and I cannot reproduce it either. Whenever you open a folder that has already been bound to the SonarQube project, the binding and corresponding connection should still be there. Would you be able to provide full SonarLint output?

This is what I’m getting:

Executing c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\jre\17.0.4.1-win32-x86_64.tar\bin\java -jar c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\server\sonarlint-ls.jar 52236 -analyzers c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarjava.jar c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarjs.jar c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarphp.jar c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarpython.jar c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarhtml.jar c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarxml.jar c:\Users\A2645399.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarcfamily.jar -extraAnalyzers c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\analyzers\sonarsecrets.jar

[stdout] Binding to 52236

Child process connected on port 52236

Java resolved to: c:\Users\XXXXXXX.vscode\extensions\sonarsource.sonarlint-vscode-3.11.0-win32-x64\jre\17.0.4.1-win32-x86_64.tar

[stderr] SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.

[stderr] SLF4J: Defaulting to no-operation (NOP) logger implementation

[stderr] SLF4J: See SLF4J Error Codes for further details.

[Info - 13:21:52.784] Started request handler on port 64120

Initializing file:///c%3A/XXXXXXX/XXXXXXX/UI on branch david/XXXXXXX

[Debug - 13:21:52.877] Fetching global configuration

[Debug - 13:21:52.885] Folder file:///c:/XXXXXXX/XXXXXXX/UI is now on branch david/XXXXXXX

[Error - 13:22:52.881] Unable to update configuration

[Error - 13:22:52.882] java.util.concurrent.TimeoutException

at java.base/java.util.concurrent.CompletableFuture.timedGet(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)

at org.sonarsource.sonarlint.ls.settings.SettingsManager.lambda$didChangeConfiguration$1(SettingsManager.java:144)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

[stderr] Nov 08, 2022 1:22:52 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError

[stderr] SEVERE: Internal error: java.lang.reflect.InvocationTargetException

[stderr] java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

[stderr] at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)

[stderr] at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)

[stderr] at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)

[stderr] at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)

[stderr] at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)

[stderr] at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)

[stderr] at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)

[stderr] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

[stderr] at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

[stderr] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

[stderr] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

[stderr] at java.base/java.lang.Thread.run(Unknown Source)

[stderr] Caused by: java.lang.reflect.InvocationTargetException

[stderr] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[stderr] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

[stderr] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

[stderr] at java.base/java.lang.reflect.Method.invoke(Unknown Source)

[stderr] at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)

[stderr] … 11 more

[stderr] Caused by: java.lang.IllegalStateException: Unable to get settings in time

[stderr] at org.sonarsource.sonarlint.ls.settings.SettingsManager.getCurrentSettings(SettingsManager.java:124)

[stderr] at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.getServerConnectionSettingsFor(ProjectBindingManager.java:204)

[stderr] at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.getServerConfigurationFor(ProjectBindingManager.java:196)

[stderr] at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.getRemoteProjects(ProjectBindingManager.java:517)

[stderr] at org.sonarsource.sonarlint.ls.SonarLintLanguageServer.getRemoteProjectsForConnection(SonarLintLanguageServer.java:470)

[stderr] … 16 more

[Debug - 13:22:52.916] Queuing analysis of file ‘file:///c:/XXXXXXX/XXXXXXX/UI/src/app/screens/alerts-preference/alerts-preference.component.ts’ (version 1)

[Debug - 13:22:52.942] Queuing analysis of file ‘file:///c:/XXXXXXX/XXXXXXX/UI/src/app/screens/consent/consent.component.ts’ (version 1)

[Debug - 13:22:53.153] Cached SCM ignore status for file ‘file:///c:/XXXXXXX/XXXXXXX/UI/src/app/screens/alerts-preference/alerts-preference.component.ts’: Not ignored

Again, what’s strange is this just happened out of nowhere. I haven’t done any major updates, added any extensions, etc. I’ll keep looking into it, as I suspect it may not be related; just was curious if it might be.

And to clarify - the above message is what pops up upon IDE load. If I try to open up my SonarQube connection in the Connected Mode section, I get

[Debug - 13:24:02.355] Received refresh request for https-sonarqube-***********-com

[Error - 13:24:52.929] Analysis failed

Hello David,
I also don’t think that the two issues (“connected mode view” and “analysis failed”) are related. Stepping back a bit:

I’m going to have to re-add the SonarQube connection each time I want to analyze a different project

Just to clarify, SonarQube Connection and Project Binding are two related, but different concepts. SonarQube Connection needs to be configured once for each SonarQube server, while the Project Binding needs to be configured for each project individually. You can find more about this in our docs.

As for the Connected Mode view - would you be willing to try installing this snapshot build of SonarLint to see if your issue persists? You will need to go to the VSCode Extensions view and choose Install from VSIX option.

Note that the Connected Mode view will be found under SonarLint view container as shown on the image.

Hope this helps,
Sophio

2 Likes

Sophio, that fixed it! Thank you so much.

I’m doing a team presentation on SonarLint Monday. Is this snapshot build something I can safely recommend to my teammates? I would assume so, just want to confirm.

1 Like

I’m happy to hear that! :tada:

Well, as it is a snapshot build, we don’t officially support it but it is still a working build and you can use it before we release v3.13 :slight_smile: :woman_shrugging:.
The link that I provided before was for a Windows-specific VSIX, you will find all platform + universal files here.

Have a good weekend :hugs:
Sophio

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.