green-code-initiative / ecoCode-android

Reduce the environmental footprint of your Java-based Android apps with SonarQube
https://ecocode.io
GNU General Public License v3.0
58 stars 18 forks source link

SonarQube server crashes at startup when both ecoCode-android and Groovy plugins are onboard #83

Open gvrf2911 opened 12 months ago

gvrf2911 commented 12 months ago

Describe the bug SonarQube 10.3 server crashes at startup when both ecoCode-android and Groovy plugins are onboard.

To Reproduce Steps to reproduce the behavior:

  1. Start SonarQube server with ecoCode-android and Groovy plugins onboard,
  2. SonarQube crashes with the following error:
023.11.29 15:41:52 INFO  web[][o.s.s.p.ServerPluginManager] Deploy ecoCode JavaScript plugin / 1.4.0 / null

2023.11.29 15:41:58 INFO  ...

2023.11.29 15:42:00 INFO  web[][o.s.s.p.DetectPluginChange] Detect plugin changes
2023.11.29 15:42:02 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
java.lang.IllegalStateException: Fail to load plugin Groovy [groovy]
    at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:81)
    at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:668)
    at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:214)
    at org.sonar.server.platform.PlatformImpl.startLevel34Containers(PlatformImpl.java:194)
    at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.runIfNotAborted(PlatformImpl.java:362)
    at org.sonar.server.platform.PlatformImpl$1.doRun(PlatformImpl.java:113)
    at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.run(PlatformImpl.java:346)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@12bcd0c0-org.sonar.api.config.PropertyDefinition-sonar.groovy.file.suffixes' defined in null: Cannot register bean definition [Generic bean: class [org.sonar.api.config.PropertyDefinition]; scope=singleton; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'jdk.internal.loader.ClassLoaders$AppClassLoader@12bcd0c0-org.sonar.api.config.PropertyDefinition-sonar.groovy.file.suffixes': There is already [Generic bean: class [org.sonar.api.config.PropertyDefinition]; scope=singleton; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition(DefaultListableBeanFactory.java:1006)
    at org.springframework.context.support.GenericApplicationContext.registerBeanDefinition(GenericApplicationContext.java:342)
    at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.registerBeanDefinition(BeanDefinitionReaderUtils.java:164)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.doRegisterBean(AnnotatedBeanDefinitionReader.java:285)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:233)
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.registerBean(AnnotationConfigApplicationContext.java:198)
    at org.sonar.core.platform.SpringComponentContainer.registerInstance(SpringComponentContainer.java:126)
    at org.sonar.core.platform.SpringComponentContainer.addExtension(SpringComponentContainer.java:142)
    at org.sonar.core.platform.SpringComponentContainer.addExtension(SpringComponentContainer.java:236)
    at org.sonar.core.platform.SpringComponentContainer.addExtension(SpringComponentContainer.java:41)
    at org.sonar.server.plugins.ServerExtensionInstaller.installExtension(ServerExtensionInstaller.java:89)
    at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:73)
    ... 7 common frames omitted
2023.11.29 15:42:02 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

Expected behavior SonarQube should start up with both plugins onboard.

Additional context

SonarQube version: 10.3.0 Enterprise Edition ecoCode-android version : 1.1.0 Groovy plugin: 1.8

SonarQube launches well with only one of the two plugins.

With the ecoCode-android plugins installed, there are 3 rules created for the Groovy language, whereas the Groovy plugin integrates 385 rules and activates 58 in the "Sonar way" profile.

Although the Groovy plugin is unmaintained, it still works on SonarQube versions 9.9 LTS, 10.2.1 and 10.3 and is used in our company.

It's a sad fact that these plugins look like to be incompatible, especially as it seems that much of the Groovy language analysis code of ecoCode-android plugin comes from the Groovy plugin.

jhertout commented 10 months ago

Hello,

sorry for the delay of the response. The fact that the two plugins can't work at the same time is a problem indeed. We will try to fix that.

Thanks