Error ‘AlreadyDisposedException’ in SonarLint for IntelliJ container is already disposed

  • Operating system: Windows 10
  • SonarLint plugin version: 10.2.1.77304
  • Programming language you’re coding in: Java
  • Is connected mode used:
    • Connected to SonarQube (and which version): SonarQube Version 9.9.1 (build 69595)
  • IntelliJ IDEA 2023.1.3 Build #IU-231.9161.38
  • JDK: 17.0.7; VM: Java HotSpot™ 64-Bit Server VM; Vendor: Oracle Corporation

An Error occurs right after attempt o establish connection to the SonarQube server or Update Local Storage:

Error updating the storage for connection ‘SonarQube’

com.intellij.openapi.progress.ProcessCanceledException: com.intellij.serviceContainer.AlreadyDisposedException: Cannot create light service org.sonarlint.intellij.core.ProjectBindingManager because container is already disposed (container=Project(name=appName, containerState=DISPOSE_COMPLETED, componentStore=C:\Users\AB26353\appName) (disposed))
	at com.intellij.serviceContainer.ContainerUtilKt.throwAlreadyDisposedError(containerUtil.kt:45)
	at com.intellij.serviceContainer.ComponentManagerImpl.checkThatCreatingOfLightServiceIsAllowed(ComponentManagerImpl.kt:790)
	at com.intellij.serviceContainer.ComponentManagerImpl.getOrCreateLightService(ComponentManagerImpl.kt:770)
	at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:726)
	at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:670)
	at org.sonarlint.intellij.common.util.SonarLintUtils.getService(SonarLintUtils.java:62)
	at org.sonarlint.intellij.module.ModulesRegistry.connectionIdFor(ModulesRegistry.kt:52)
	at org.sonarlint.intellij.module.ModulesRegistry.getModulesForEngine(ModulesRegistry.kt:39)
	at org.sonarlint.intellij.core.SonarLintEngineFactory.lambda$createEngine$0(SonarLintEngineFactory.java:57)
	at org.sonarsource.sonarlint.core.analysis.container.global.ModuleRegistry.<init>(ModuleRegistry.java:42)
	at org.sonarsource.sonarlint.core.analysis.container.global.GlobalAnalysisContainer.doAfterStart(GlobalAnalysisContainer.java:71)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.startComponents(SpringComponentContainer.java:182)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine.start(AnalysisEngine.java:58)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine.<init>(AnalysisEngine.java:53)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.loadAnalysisContext(ConnectedSonarLintEngineImpl.java:132)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.start(ConnectedSonarLintEngineImpl.java:115)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.<init>(ConnectedSonarLintEngineImpl.java:105)
	at org.sonarlint.intellij.core.SonarLintEngineFactory.createEngine(SonarLintEngineFactory.java:62)
	at org.sonarlint.intellij.core.DefaultEngineManager.lambda$createConnectedEngine$2(DefaultEngineManager.java:118)
	at java.base/java.util.Optional.map(Optional.java:260)
	at org.sonarlint.intellij.core.DefaultEngineManager.createConnectedEngine(DefaultEngineManager.java:118)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
	at org.sonarlint.intellij.core.DefaultEngineManager.getConnectedEngine(DefaultEngineManager.java:112)
	at org.sonarlint.intellij.tasks.BindingStorageUpdateTask.run(BindingStorageUpdateTask.java:106)
	at org.sonarlint.intellij.tasks.BindingStorageUpdateTask$1.run(BindingStorageUpdateTask.java:84)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:429)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressSynchronously$9(CoreProgressManager.java:513)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$new$0(ProgressRunner.java:84)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.intellij.serviceContainer.AlreadyDisposedException: Cannot create light service org.sonarlint.intellij.core.ProjectBindingManager because container is already disposed (container=Project(name=appName, containerState=DISPOSE_COMPLETED, componentStore=C:\Users\AB26353\appName) (disposed))
	at com.intellij.serviceContainer.ContainerUtilKt.throwAlreadyDisposedError(containerUtil.kt:40)
	... 45 more

Looks after Disabl/Enable SonarLint plugin and restart Intellij Idea the issue has gone.

but another one has occurs:
Using connection ‘SonarQube’ for project ‘appName’
Analysing ‘EnableMdcLogAspect.java’…
Found 1 issue and 0 hotspots

Error while retrieving the list of allowed statuses for issues

org.sonarsource.sonarlint.core.serverapi.exception.UnexpectedBodyException: No issue found with key 'AY0dtMHeUwy-xxxxxxx'
	at org.sonarsource.sonarlint.core.serverapi.issue.IssueApi.lambda$searchByKey$15(IssueApi.java:258)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Hi @infosecurity, thank you for your report.

About the first error, we acknowledge that this kind of error can happen, and we are currently working on fixing it. Do you know if you did any actions following the connection to SonarQube, perhaps closing a project?

About the second error, I would need a bit more information. Do you still reproduce the issue?
Is AY0dtMHeUwy-xxxxxxx the real issue key? If not, could you please share it with us?

Hi Nicolas Quinquenel, thanks for your response

2nd option:
Error while retrieving the list of allowed statuses for issues
org.sonarsource.sonarlint.core.serverapi.exception.UnexpectedBodyException: No issue found with key ‘AY0dtMDUUwy-ftQ837wN’

Initially I had installed an old version of SonarLint plugin: like 6.x.x.
I did several attempts to connect to the Sonar Qube server, but no luck some errors were occurred
next I updated/re-installed the SonarLint plugin to the actual version, IDE restart was required
after Intellij Idea was restarted it becomes broken and didn’t start correct, only Logo appeared for few seconds and gone

I’ve finally started my IDE in the recovery mode (.bat file) and disabled SonarLint plugin -
its solved my issue with starting IDE in default mode

after few more attempts disable/enable/re-install the SonarLint plugin I’ve achieved the stable one instance.

Hope described scenario will help you with issue investigations

1 Like

Regarding the issue No issue found with key, the local storage in SonarLint is probably not in sync with the SonarQube server anymore.

Could you try deleting the connection and re-creating it again?

Thanks :sonarlint:

1 Like

After these steps were performed getting the issue below:

Found 1 issue and 0 hotspots
Error while retrieving the list of allowed statuses for issues

org.sonarsource.sonarlint.core.serverapi.exception.UnexpectedBodyException: No issue found with key '**AYeZWZAn1WVP3yy83P4w**'
	at org.sonarsource.sonarlint.core.serverapi.issue.IssueApi.lambda$searchByKey$15(IssueApi.java:258)

In this case I would recommend you to delete the folder under <projectBaseDir>/.idea/sonarlint/issuestore and try to re-trigger an analysis on the file.

1 Like
  1. removed SonarLint base folder completely /.idea/sonarlint ;
  2. re-created a connection from scratch;
  3. choose a project key
  4. clicked Apply

Update Local Storage was initiated automatically with the issue below:

com.intellij.serviceContainer.AlreadyDisposedException: 
Cannot create light service org.sonarlint.intellij.core.ProjectBindingManager because container is already disposed 
(container=Project(name=eflow-ls-amtopalintegration, containerState=DISPOSE_COMPLETED, componentStore=C:\Users\USER\Projects\<projectBaseDir>) (disposed))

FYI: the same issue has occurred on very first Plugin initialization, but skipped…
Update Local Storage was performed later, manually at Plugin Project Settings.

UPD:

any further attempt to perform Update Local Storage synchronization has produced the issue mentioned above, until the Intellij IDEA was restarted.
After the restart I’ve observed the Error below in general Idea logs:

Exception thrown by subscriber method handleEvent(org.sonarsource.sonarlint.core.event.ConnectionConfigurationRemovedEvent) on subscriber org.sonarsource.sonarlint.core.storage.StorageService@4866ceec when dispatching event: org.sonarsource.sonarlint.core.event.ConnectionConfigurationRemovedEvent@1f6abdc9

java.lang.IllegalStateException: Unable to delete directory C:\Users\USER\AppData\Local\JetBrains\IntelliJIdea2023.1\sonarlint\storage\536f6e617251756265
	at org.sonarsource.sonarlint.core.serverconnection.FileUtils.deleteRecursively(FileUtils.java:88)
	at org.sonarsource.sonarlint.core.serverconnection.ConnectionStorage.delete(ConnectionStorage.java:65)
	at org.sonarsource.sonarlint.core.storage.StorageService.handleEvent(StorageService.java:64)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:85)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:142)
	at com.google.common.eventbus.Subscriber.lambda$dispatchEvent$0(Subscriber.java:71)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

After deleting the mentioned […\IntelliJIdea2023.1\ sonarlint] directory manually, Idea has started proper without any errors.
And for now I can see a connectivity Icon status (cloud icon located right bottom of SonarLint plugin’s Panel) as “Connected to SonarQube” white color, instead red one previously…

and new directory was created with some config files:

 Directory of C:\Users\USER\AppData\Local\JetBrains\IntelliJIdea2023.1\sonarlint\storage\536f6e617251756265\projects\3136303033385f65666c6f772d6c735f65666c6f772d6c732d616d746f70616c696e746567726174696f6e

02/10/2024  11:03 PM    <DIR>          .
02/10/2024  11:03 PM    <DIR>          ..
02/10/2024  11:03 PM            62,877 analyzer_config.pb
02/10/2024  11:03 PM                 0 component_list.pb
02/10/2024  11:03 PM               281 project_branches.pb

For now if I click Update Local Storage in the plugin settings - no errors occurs,
looks like synchronization performs proper, but still getting the error on attempt to Mark issue as… Btn click:

Error while retrieving the list of allowed statuses for issues
org.sonarsource.sonarlint.core.serverapi.exception.UnexpectedBodyException: No issue found with key ‘AYeZWZAn1WVP3yy83P4w
at org.sonarsource.sonarlint.core.serverapi.issue.IssueApi.lambda$searchByKey$15(IssueApi.java:258)

1 Like