Rule declared several times in Connected Mode (InternalError)

Same problem here.

Here are the requested logs. The error happens whenever I save a file in the Eclipse IDE.

File content changed: /.../YYY.java
Language of file "file:/.../YYY.java" is detected to be "JAVA"
Module file event for [uri=file:/.../YYY.java] has been ignored because it's not a Python file.
Computing file exclusion for uri 'file:/.../YYY.java'
Server excluded sources: 
  **/build-wrapper-dump.json
File exclusion for uri 'file:/.../YYY.java' is false
Trigger: EDITOR_CHANGE
Analysis started with the engines being ready
SonarLint processing file /.../YYY.java...
  * css: 0 active rules
  * scala: 30 active rules
Extracting rules metadata for connection 'SonarCloud'
Internal error: java.lang.IllegalStateException: Unable to extract rules metadata

java.util.concurrent.CompletionException: java.lang.IllegalStateException: Unable to extract rules metadata
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(Unknown Source)
	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)
Caused by: java.lang.IllegalStateException: Unable to extract rules metadata
	at org.sonarsource.sonarlint.core.rule.extractor.RulesDefinitionExtractor.extractRules(RulesDefinitionExtractor.java:42)
	at org.sonarsource.sonarlint.core.rules.RulesExtractionHelper.extractRulesForConnection(RulesExtractionHelper.java:57)
	at org.sonarsource.sonarlint.core.repository.rules.RulesRepository.lazyInit(RulesRepository.java:81)
	at org.sonarsource.sonarlint.core.repository.rules.RulesRepository.getRule(RulesRepository.java:72)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.tryConvertDeprecatedKeys(AnalysisService.java:373)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.lambda$buildConnectedActiveRules$6(AnalysisService.java:278)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.buildConnectedActiveRules(AnalysisService.java:272)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.lambda$getAnalysisConfig$0(AnalysisService.java:229)
	at java.base/java.util.Optional.map(Unknown Source)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.getAnalysisConfig(AnalysisService.java:229)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.getAnalysisConfigForEngine(AnalysisService.java:236)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.analyze(AnalysisService.java:546)
	at org.sonarsource.sonarlint.core.rpc.impl.AnalysisRpcServiceDelegate.lambda$analyzeFilesAndTrack$8(AnalysisRpcServiceDelegate.java:128)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.lambda$requestAsync$0(AbstractRpcServiceDelegate.java:67)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.computeWithLogger(AbstractRpcServiceDelegate.java:135)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.lambda$requestAsync$1(AbstractRpcServiceDelegate.java:65)
	... 5 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:132)
	at org.sonarsource.sonarlint.core.rule.extractor.RulesDefinitionExtractorContainer.doAfterStart(RulesDefinitionExtractorContainer.java:79)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.startComponents(SpringComponentContainer.java:182)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.execute(SpringComponentContainer.java:161)
	at org.sonarsource.sonarlint.core.rule.extractor.RulesDefinitionExtractor.extractRules(RulesDefinitionExtractor.java:39)
	... 29 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@7d836c99-org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The rule 'S2259' of repository 'java' is declared several times
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:310)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:291)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1284)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1245)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1178)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:130)
	... 33 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The rule 'S2259' of repository 'java' is declared several times
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:306)
	... 49 common frames omitted
Caused by: java.lang.IllegalArgumentException: The rule 'S2259' of repository 'java' is declared several times
	at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
	at org.sonar.api.server.rule.internal.DefaultNewRepository.createRule(DefaultNewRepository.java:82)
	at org.sonar.api.server.rule.RulesDefinitionAnnotationLoader.loadRule(RulesDefinitionAnnotationLoader.java:82)
	at org.sonar.api.server.rule.RulesDefinitionAnnotationLoader.loadRule(RulesDefinitionAnnotationLoader.java:70)
	at org.sonar.api.server.rule.RulesDefinitionAnnotationLoader.load(RulesDefinitionAnnotationLoader.java:62)
	at org.sonarsource.analyzer.commons.RuleMetadataLoader.addAnnotatedRule(RuleMetadataLoader.java:122)
	at org.sonarsource.analyzer.commons.RuleMetadataLoader.addRuleByAnnotatedClass(RuleMetadataLoader.java:99)
	at org.sonarsource.analyzer.commons.RuleMetadataLoader.addRulesByAnnotatedClass(RuleMetadataLoader.java:88)
	at org.sonar.java.se.plugin.JavaSECheckRegistrar.customRulesDefinition(JavaSECheckRegistrar.java:77)
	at org.sonar.plugins.java.JavaRulesDefinition.define(JavaRulesDefinition.java:89)
	at org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader.<init>(RuleDefinitionsLoader.java:35)
	at jdk.internal.reflect.GeneratedConstructorAccessor77.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
	... 51 common frames omitted

Error during execution of SonarLint analysis
java.lang.IllegalStateException: java.util.concurrent.ExecutionException: org.sonarsource.sonarlint.shaded.org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at org.sonarlint.eclipse.core.internal.jobs.AnalyzeProjectJob.run(AnalyzeProjectJob.java:307)
	at org.sonarlint.eclipse.core.internal.jobs.AnalyzeProjectJob.doRun(AnalyzeProjectJob.java:155)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractSonarJob.run(AbstractSonarJob.java:37)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.util.concurrent.ExecutionException: org.sonarsource.sonarlint.shaded.org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
	at org.sonarlint.eclipse.core.internal.utils.JobUtils.waitForFutureInJob(JobUtils.java:74)
	at org.sonarlint.eclipse.core.internal.jobs.AnalyzeProjectJob.run(AnalyzeProjectJob.java:293)
	... 3 more
Caused by: org.sonarsource.sonarlint.shaded.org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at org.sonarsource.sonarlint.shaded.org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:220)
	at org.sonarsource.sonarlint.shaded.org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:204)
	at org.sonarsource.sonarlint.core.rpc.protocol.SingleThreadedMessageConsumer.lambda$new$0(SingleThreadedMessageConsumer.java:51)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	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:840)

This post was split up from New install of SonarLint fails with ResponseErrorException InternalError

Hi @sithmein,

I moved this to a separate thread as it is not the same error, but only noticeable when looking at the details :smile:

I see that you are in Connected Mode to SonarCloud here. While I flag this for my colleagues, would you be willing to remove the connection and then add it again?

I’d like to see if the issue might be caused by analyzers that were updated on SonarCloud and then downloaded to your machine, creating an issue here.

Best,
Tobias

1 Like

I removed the Sonarcloud binding on a project and re-added it. The problem persists. Then I removed the whole SonarCloud connection, re-added it and re-bound the project and now the error is gone.

2 Likes

Hi @sithmein,

You hit this known bug. Indeed, re-creating the connection is a valid workaround. Given other priorities, I don’t think we will be able to fix it soon.

Thanks for reporting