在 IntelliJ 中设置 SonarLint 时出现异常

Exception during setting up SonarLint in IntelliJ

我正在使用 IntelliJ (v2018.1.2) 并尝试让 SonarLint (3.3.0.2482) 插件工作。当我在 SonarLint 面板上 select Configure SonarLint 并在选中 Enable binding to remote SonarQube server 后单击 Configure Servers... 时,它什么也没做,并给我以下错误。

SonarLint 安装指南说你只需要 Java 8,我有 (1.8.0) 并从插件目录安装它 -> 浏览我所做的存储库。我已经尝试更新 IntelliJ 和 SonarLint 并删除任何未自动包含在 IntelliJ 中的插件,并查看它们是否正在交互但不确定从这里去哪里。还有其他人遇到这个吗?感谢阅读。

完整的异常文本在这里:

com/google/common/collect/ImmutableList
java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
    at org.sonar.plugins.java.JavaPlugin.getExtensions(JavaPlugin.java:50)
    at org.sonar.api.SonarPlugin.define(SonarPlugin.java:51)
    at org.sonarsource.sonarlint.core.container.global.ExtensionInstaller.install(ExtensionInstaller.java:55)
    at org.sonarsource.sonarlint.core.container.global.GlobalExtensionContainer.doBeforeStart(GlobalExtensionContainer.java:37)
    at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:123)
    at org.sonarsource.sonarlint.core.container.storage.StorageContainer.doAfterStart(StorageContainer.java:118)
    at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:125)
    at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.start(ConnectedSonarLintEngineImpl.java:120)
    at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.<init>(ConnectedSonarLintEngineImpl.java:79)
    at org.sonarlint.intellij.core.SonarLintEngineFactory.createEngine(SonarLintEngineFactory.java:63)
    at org.sonarlint.intellij.core.SonarLintEngineManager.getConnectedEngine(SonarLintEngineManager.java:110)
    at org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.switchTo(SonarQubeServerMgmtPanel.java:283)
    at org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.onServerSelect(SonarQubeServerMgmtPanel.java:272)
    at org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.lambda$create[=10=](SonarQubeServerMgmtPanel.java:121)
    at javax.swing.JList.fireSelectionValueChanged(JList.java:1796)
    at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1810)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:184)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:164)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:211)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:405)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:415)
    at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:459)
    at javax.swing.JList.setSelectedIndex(JList.java:2210)
    at javax.swing.JList.setSelectedValue(JList.java:2360)
    at org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.load(SonarQubeServerMgmtPanel.java:262)
    at org.sonarlint.intellij.config.global.SonarLintGlobalConfigurable.reset(SonarLintGlobalConfigurable.java:98)
    at com.intellij.openapi.options.ex.ConfigurableCardPanel.reset(ConfigurableCardPanel.java:124)
    at com.intellij.openapi.options.ex.ConfigurableCardPanel.lambda$createConfigurableComponent[=10=](ConfigurableCardPanel.java:82)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:927)
    at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:47)
    at com.intellij.openapi.options.ex.ConfigurableCardPanel.createConfigurableComponent(ConfigurableCardPanel.java:69)
    at com.intellij.openapi.options.ex.ConfigurableCardPanel.create(ConfigurableCardPanel.java:55)
    at com.intellij.openapi.options.newEditor.ConfigurableEditor.create(ConfigurableEditor.java:73)
    at com.intellij.openapi.options.newEditor.ConfigurableEditor.create(ConfigurableEditor.java:70)
    at com.intellij.ui.CardLayoutPanel.createValue(CardLayoutPanel.java:88)
    at com.intellij.ui.CardLayoutPanel.select(CardLayoutPanel.java:116)
    at com.intellij.ui.CardLayoutPanel.select(CardLayoutPanel.java:101)
    at com.intellij.openapi.options.newEditor.ConfigurableEditor.<init>(ConfigurableEditor.java:114)
    at com.intellij.openapi.options.newEditor.SettingsDialog.<init>(SettingsDialog.java:49)
    at com.intellij.openapi.options.newEditor.SettingsDialogFactory.create(SettingsDialogFactory.java:37)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:231)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:217)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:212)
    at org.sonarlint.intellij.config.project.SonarLintProjectBindPanel.actionConfigureServers(SonarLintProjectBindPanel.java:288)
    at org.sonarlint.intellij.config.project.SonarLintProjectBindPanel.access0(SonarLintProjectBindPanel.java:67)
    at org.sonarlint.intellij.config.project.SonarLintProjectBindPanel.actionPerformed(SonarLintProjectBindPanel.java:223)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6541)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3325)
    at java.awt.Component.processEvent(Component.java:6306)
    at java.awt.Container.processEvent(Container.java:2237)
    at java.awt.Component.dispatchEventImpl(Component.java:4897)
    at java.awt.Container.dispatchEventImpl(Container.java:2295)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
    at java.awt.Container.dispatchEventImpl(Container.java:2281)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
    at java.awt.EventQueue.access0(EventQueue.java:98)
    at java.awt.EventQueue.run(EventQueue.java:715)
    at java.awt.EventQueue.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue.run(EventQueue.java:737)
    at java.awt.EventQueue.run(EventQueue.java:735)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:779)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:716)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:395)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
    at java.awt.WaitDispatchSupport.run(WaitDispatchSupport.java:190)
    at java.awt.WaitDispatchSupport.run(WaitDispatchSupport.java:235)
    at java.awt.WaitDispatchSupport.run(WaitDispatchSupport.java:233)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
    at java.awt.Dialog.show(Dialog.java:1077)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:694)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:426)
    at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.java:1688)
    at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1637)
    at com.intellij.openapi.options.newEditor.SettingsDialog.lambda$show[=10=](SettingsDialog.java:69)
    at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
    at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:153)
    at com.intellij.openapi.options.newEditor.SettingsDialog.show(SettingsDialog.java:69)
    at com.intellij.openapi.ui.DialogWrapper.showAndGet(DialogWrapper.java:1652)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:241)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:202)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:191)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:175)
    at org.sonarlint.intellij.actions.SonarConfigureProject.actionPerformed(SonarConfigureProject.java:38)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.run(ActionUtil.java:220)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:237)
    at com.intellij.openapi.actionSystem.impl.ActionButton.actionPerformed(ActionButton.java:193)
    at com.intellij.openapi.actionSystem.impl.ActionButton.performAction(ActionButton.java:153)
    at com.intellij.openapi.actionSystem.impl.ActionButton.processMouseEvent(ActionButton.java:357)
    at java.awt.Component.processEvent(Component.java:6306)
    at java.awt.Container.processEvent(Container.java:2237)
    at java.awt.Component.dispatchEventImpl(Component.java:4897)
    at java.awt.Container.dispatchEventImpl(Container.java:2295)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
    at java.awt.Container.dispatchEventImpl(Container.java:2281)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
    at java.awt.EventQueue.access0(EventQueue.java:98)
    at java.awt.EventQueue.run(EventQueue.java:715)
    at java.awt.EventQueue.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue.run(EventQueue.java:737)
    at java.awt.EventQueue.run(EventQueue.java:735)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:779)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:716)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:395)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
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)
    ... 139 more

在 SonarLint google 组中,有人建议 SonarLint 正在引入旧版本的插件并检查插件库的内容。这个版本的内容是:

commons-lang-2.6.jar 
jsr305-2.0.2.jar 
sonarlint-client-api-3.3.0.1492.jar 
sonarlint-core-3.3.0.1492.jar 
sonarlint-intellij-3.3.0.2482.jar

经验证无误。此外,建议清除.../config/plugins/SonarLint 中的所有本地存储以删除本地数据缓存。

我还从 IntelliJ 中删除了任何以前版本的本地缓存,这些缓存显然在每次发布后都没有得到清理。

执行上述操作解决了问题。

对于 Sonar Lint 插件 (v4.0.2.3009) 我遇到了类似的问题,配置服务器按钮没有打开。如果您之前在 IDE(IntelliJ2019.3) 的 Sonar Lint 中完成了 Sonar Qube 的配置,则存在 off-chance,您可能会在尝试时从插件中得到 java 错误配置新服务器或选择不再响应的已配置服务器后,您将无法配置其他服务器,因为用于配置服务器的 window 不再打开。卸载插件不会删除配置的服务器。因此,为了让插件再次工作,您需要执行以下操作:

  • 卸载插件并关闭IDE
  • 从以下路径删除 "sonarlint" 文件夹“~/Library/Preferences/IntelliJIdea2019.1/”
  • 同时删除 ~Library/Preferences/IntelliJIdea2019.1/options/sonarlint.xml
  • 不确定是否需要,但我也删除了插件缓存,它位于“~/Library/Caches/IntelliJIdea2019.1/plugins/”
  • 重新安装插件并配置新服务器