Error in sonarqube integrating gitlab cicd

Must-share information (formatted with Markdown):

  • SonarQube 9.6.1 Scanner4.6.2 Plugin 4.0

gitlab-ci.yml

stages: 
  - sonarqube-check 
sonarqube-check: 
  stage: sonarqube-check 

  variables: 

    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache 

    SCANNER_HOME: "/opt/tool/sonar-scanner" 

    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task 

  cache: 

    key: "${CI_JOB_NAME}" 

    paths: 

      - .sonar/cache 

  script: 

    - /opt/tool/sonar-scanner/bin/sonar-scanner 

  allow_failure: true 

  tags: 

    - dev 

  only: 

    - main # or the name of your main branch

ERROR:

INFO: EXECUTION FAILURE

[139](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L139)INFO: ------------------------------------------------------------------------

[140](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L140)INFO: Total time: 23.600s

[141](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L141)INFO: Final Memory: 25M/90M

[142](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L142)INFO: ------------------------------------------------------------------------

[143](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L143)ERROR: Error during SonarScanner execution

[144](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L144)java.lang.IllegalStateException: Unable to load components interface org.sonar.api.batch.postjob.PostJob

[145](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L145) at org.sonar.core.platform.SpringComponentContainer.getComponentsByType(SpringComponentContainer.java:156)

[146](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L146) at org.sonar.scanner.bootstrap.AbstractExtensionDictionary.completeScannerExtensions(AbstractExtensionDictionary.java:82)

[147](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L147) at org.sonar.scanner.bootstrap.AbstractExtensionDictionary.getExtensions(AbstractExtensionDictionary.java:77)

[148](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L148) at org.sonar.scanner.bootstrap.AbstractExtensionDictionary.getFilteredExtensions(AbstractExtensionDictionary.java:67)

[149](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L149) at org.sonar.scanner.bootstrap.PostJobExtensionDictionary.selectPostJobs(PostJobExtensionDictionary.java:42)

[150](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L150) at org.sonar.scanner.postjob.PostJobsExecutor.execute(PostJobsExecutor.java:38)

[151](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L151) at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:376)

[152](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L152) at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)

[153](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L153) at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)

[154](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L154) at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:135)

[155](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L155) at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)

[156](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L156) at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)

[157](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L157) at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)

[158](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L158) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)

[159](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L159) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)

[160](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L160) at [java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native](http://java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native) Method)

[161](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L161) at [java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown](http://java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown) Source)

[162](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L162) at [java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown](http://java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown) Source)

[163](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L163) at [java.base/java.lang.reflect.Method.invoke(Unknown](http://java.base/java.lang.reflect.Method.invoke(Unknown) Source)

[164](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L164) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)

[165](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L165) at com.sun.proxy.$Proxy0.execute(Unknown Source)

[166](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L166) at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)

[167](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L167) at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)

[168](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L168) at org.sonarsource.scanner.cli.Main.execute(Main.java:112)

[169](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L169) at org.sonarsource.scanner.cli.Main.execute(Main.java:75)

[170](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L170) at org.sonarsource.scanner.cli.Main.main(Main.java:61)

[171](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L171)Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ClassRealm{gitlab}-com.talanlabs.sonar.plugins.gitlab.CommitPublishPostJob': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.talanlabs.sonar.plugins.gitlab.CommitPublishPostJob] from ClassLoader [ClassRealm{gitlab}]

[172](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L172) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289)

[173](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L173) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1302)

[174](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L174) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219)

[175](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L175) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)

[176](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L176) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)

[177](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L177) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)

[178](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L178) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)

[179](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L179) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)

[180](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L180) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)

[181](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L181) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:671)

[182](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L182) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:659)

[183](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L183) at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1300)

[184](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L184) at org.sonar.core.platform.SpringComponentContainer.getComponentsByType(SpringComponentContainer.java:154)

[185](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L185) ... 25 more

[186](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L186)Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.talanlabs.sonar.plugins.gitlab.CommitPublishPostJob] from ClassLoader [ClassRealm{gitlab}]

[187](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L187) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)

[188](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L188) at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)

[189](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L189) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)

[190](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L190) ... 37 more

[191](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L191)Caused by: java.lang.NoClassDefFoundError: org/sonar/api/batch/postjob/issue/PostJobIssue

[192](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L192) at [java.base/java.lang.Class.getDeclaredMethods0(Native](http://java.base/java.lang.Class.getDeclaredMethods0(Native) Method)

[193](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L193) at [java.base/java.lang.Class.privateGetDeclaredMethods(Unknown](http://java.base/java.lang.Class.privateGetDeclaredMethods(Unknown) Source)

[194](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L194) at [java.base/java.lang.Class.getDeclaredMethods(Unknown](http://java.base/java.lang.Class.getDeclaredMethods(Unknown) Source)

[195](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L195) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)

[196](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L196) ... 39 more

[197](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L197)Caused by: java.lang.ClassNotFoundException: org.sonar.api.batch.postjob.issue.PostJobIssue

[198](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L198) at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)

[199](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L199) at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)

[200](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L200) at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)

[201](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L201) ... 43 more

[202](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L202)ERROR:

[203](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L203)ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

[205](http://10.16.88.68:10001/gitlab-instance-08045261/example/-/jobs/25#L205)ERROR: Job failed: exit status 1
  • gitlab cicd can trigger sonar-scanner ,but it will be appear some error lead to pipeline cannot run to the last。i want to know how to fix it to complete this pipeline**

Thank you

Hey there.

Check this post.