添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Sonarlint 7.9
Eclipse 2023-03 (4.27)

In Eclipse, when sonarlint is downloading the rules from the Sonarqube server, it gives this error:
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList
at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)

Any soluction?

This is log:

!ENTRY org.sonarlint.eclipse.core 4 0 2023-04-28 09:32:31.702
!MESSAGE Unable to update SonarLint binding data for project 'myproject' on 'mysonar'
!STACK 0
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.AbstractSonarLintEngine.loadPluginMetadata(AbstractSonarLintEngine.java:77)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.loadAnalysisContext(ConnectedSonarLintEngineImpl.java:120)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.start(ConnectedSonarLintEngineImpl.java:112)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.restartAnalysisEngine(ConnectedSonarLintEngineImpl.java:317)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.sync(ConnectedSonarLintEngineImpl.java:312)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.sync(ConnectedEngineFacade.java:550)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.lambda$36(ConnectedEngineFacade.java:544)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.doWithEngine(ConnectedEngineFacade.java:159)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.manualSync(ConnectedEngineFacade.java:543)
	at org.sonarlint.eclipse.core.internal.jobs.ProjectStorageUpdateJob.lambda$0(ProjectStorageUpdateJob.java:46)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at org.sonarlint.eclipse.core.internal.jobs.ProjectStorageUpdateJob.run(ProjectStorageUpdateJob.java:44)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
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)
	... 13 more
Caused by: org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.eclipse.osgi.internal.loader.EquinoxClassLoader@9cdef42[org.sonarsource.sonarlint.core.sonarlint-core-osgi:8.14.0.63103(id=946)]-org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader': Bean instantiation via constructor failed; nested exception is org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:296)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1284)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1245)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
	at org.sonarsource.sonarlint.shaded.org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1172)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:130)
	... 17 more
Caused by: org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:311)
	... 33 more
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
	at es.atos.madriddigital.sonar.mova.javascript.JavaScriptRulesList.getChecks(JavaScriptRulesList.java:18)
	at es.atos.madriddigital.sonar.mova.javascript.JavaScriptCustomRulesDefinition.checkClasses(JavaScriptCustomRulesDefinition.java:72)
	at es.atos.madriddigital.sonar.mova.javascript.JavaScriptCustomRulesDefinition.define(JavaScriptCustomRulesDefinition.java:49)
	at org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader.<init>(RuleDefinitionsLoader.java:35)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
	... 35 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList
	at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
	... 45 more

Thank you

This is log:

!ENTRY org.sonarlint.eclipse.core 4 0 2023-04-28 09:32:31.702
!MESSAGE Unable to update SonarLint binding data for project 'XXXXXXX' on 'MySonarqube'
!STACK 0
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.AbstractSonarLintEngine.loadPluginMetadata(AbstractSonarLintEngine.java:77)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.loadAnalysisContext(ConnectedSonarLintEngineImpl.java:120)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.start(ConnectedSonarLintEngineImpl.java:112)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.restartAnalysisEngine(ConnectedSonarLintEngineImpl.java:317)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.sync(ConnectedSonarLintEngineImpl.java:312)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.sync(ConnectedEngineFacade.java:550)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.lambda$36(ConnectedEngineFacade.java:544)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.doWithEngine(ConnectedEngineFacade.java:159)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.manualSync(ConnectedEngineFacade.java:543)
	at org.sonarlint.eclipse.core.internal.jobs.ProjectStorageUpdateJob.lambda$0(ProjectStorageUpdateJob.java:46)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at org.sonarlint.eclipse.core.internal.jobs.ProjectStorageUpdateJob.run(ProjectStorageUpdateJob.java:44)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
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)
	... 13 more
Caused by: org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.eclipse.osgi.internal.loader.EquinoxClassLoader@9cdef42[org.sonarsource.sonarlint.core.sonarlint-core-osgi:8.14.0.63103(id=946)]-org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader': Bean instantiation via constructor failed; nested exception is org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:296)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1284)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1245)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
	at org.sonarsource.sonarlint.shaded.org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1172)
	at org.sonarsource.sonarlint.core.plugin.commons.container.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:130)
	... 17 more
Caused by: org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:311)
	... 33 more
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
	at es.atos.madriddigital.sonar.mova.javascript.JavaScriptRulesList.getChecks(JavaScriptRulesList.java:18)
	at es.atos.madriddigital.sonar.mova.javascript.JavaScriptCustomRulesDefinition.checkClasses(JavaScriptCustomRulesDefinition.java:72)
	at es.atos.madriddigital.sonar.mova.javascript.JavaScriptCustomRulesDefinition.define(JavaScriptCustomRulesDefinition.java:49)
	at org.sonarsource.sonarlint.core.rule.extractor.RuleDefinitionsLoader.<init>(RuleDefinitionsLoader.java:35)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.sonarsource.sonarlint.shaded.org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
	... 35 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList
	at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
	... 45 more
              

Hi @Thorin

From the stacktrace, I see that the error is caused by a third-party plugin:
es.atos.madriddigital.sonar.mova.javascript.JavaScriptRulesList

I don’t know this plugin, so I can only guess that it is not properly shading its dependencies. The solutions I can see are:

  • fix this plugin packaging (shade the Guava dependency)
  • remove the plugin from your SonarQube server (only if you have no use of it)
  • remove the flag in the plugin telling it is SonarLint compatible so that it is not loaded by SonarLint anymore
  •