Analysis is Failing

maven
(Tulasi Perigisetti) #1

Hi Team,

We are trying to run a SonarQube analysis in Jenkins.

Few builds are failing with below error:

   2:46:39 [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.1.1168:sonar (default-cli) on project XXX: 316 -> [Help 1]
12:46:39 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.1.1168:sonar (default-cli) on project XXX 316
12:46:39 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
12:46:39 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
12:46:39 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
12:46:39 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
12:46:39 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
12:46:39 	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
12:46:39 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
12:46:39 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
12:46:39 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
12:46:39 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
12:46:39 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
12:46:39 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
12:46:39 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
12:46:39 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:46:39 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
12:46:39 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12:46:39 	at java.lang.reflect.Method.invoke(Method.java:483)
12:46:39 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
12:46:39 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
12:46:39 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
12:46:39 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
12:46:39 Caused by: org.apache.maven.plugin.MojoExecutionException: 316
12:46:39 	at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:67)
12:46:39 	at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:104)
12:46:39 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
12:46:39 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
12:46:39 	... 20 more
12:46:39 Caused by: java.lang.ArrayIndexOutOfBoundsException: 316
12:46:39 	at org.sonar.scanner.issue.tracking.FileHashes.lambda$create$0(FileHashes.java:56)
12:46:39 	at org.sonar.scanner.issue.tracking.FileHashes$$Lambda$337/275682957.consume(Unknown Source)
12:46:39 	at org.sonar.api.batch.fs.internal.charhandler.LineHashComputer.processBuffer(LineHashComputer.java:76)
12:46:39 	at org.sonar.api.batch.fs.internal.charhandler.LineHashComputer.newLine(LineHashComputer.java:59)
12:46:39 	at org.sonar.api.batch.fs.internal.FileMetadata.read(FileMetadata.java:125)
12:46:39 	at org.sonar.api.batch.fs.internal.FileMetadata.readFile(FileMetadata.java:95)
12:46:39 	at org.sonar.api.batch.fs.internal.FileMetadata.computeLineHashesForIssueTracking(FileMetadata.java:158)
12:46:39 	at org.sonar.scanner.issue.tracking.FileHashes.create(FileHashes.java:55)
12:46:39 	at org.sonar.scanner.issue.tracking.SourceHashHolder.initHashes(SourceHashHolder.java:47)
12:46:39 	at org.sonar.scanner.issue.tracking.SourceHashHolder.getHashedReference(SourceHashHolder.java:64)
12:46:39 	at org.sonar.scanner.issue.tracking.LocalIssueTracking.createBaseInput(LocalIssueTracking.java:116)
12:46:39 	at org.sonar.scanner.issue.tracking.LocalIssueTracking.trackIssues(LocalIssueTracking.java:93)
12:46:39 	at org.sonar.scanner.issue.tracking.IssueTransition.trackIssues(IssueTransition.java:103)
12:46:39 	at org.sonar.scanner.issue.tracking.IssueTransition.execute(IssueTransition.java:81)
12:46:39 	at org.sonar.scanner.phases.IssuesPhaseExecutor.localIssueTracking(IssuesPhaseExecutor.java:64)
12:46:39 	at org.sonar.scanner.phases.IssuesPhaseExecutor.executeOnRoot(IssuesPhaseExecutor.java:56)
12:46:39 	at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:93)
12:46:39 	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:177)
12:46:39 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
12:46:39 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
12:46:39 	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:291)
12:46:39 	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:286)
12:46:39 	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:264)
12:46:39 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
12:46:39 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
12:46:39 	at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
12:46:39 	at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
12:46:39 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
12:46:40 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
12:46:40 	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
12:46:40 	at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
12:46:40 	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
12:46:40 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
12:46:40 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:46:40 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
12:46:40 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12:46:40 	at java.lang.reflect.Method.invoke(Method.java:483)
12:46:40 	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
12:46:40 	at com.sun.proxy.$Proxy23.execute(Unknown Source)
12:46:40 	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
12:46:40 	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
12:46:40 	at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)
12:46:40 	... 23 more

And for few builds, SonarQube analysis is successful, however the quality gate in the UI is still showing as “Failed”

Please help us.

Best Regards
Tulasi Perigisetti

(Tulasi Perigisetti) #2

Hi Team,

Please help us in resolving the issue.

Best Regards
Tulasi Perigisetti

(Janos Gyerik) #6

Hi, and sorry about the late response.

Can you please tell us the version of the SonarQube server?

Thanks,
Janos

(Tulasi Perigisetti) #7

Hi Janos,

Thanks for the response.

We are using SonarQube LTS 6.7.5 version.

Best regards
Tulasi Perigisetti

(Janos Gyerik) #8

I took a closer look at the related code. It seems such issue could happen if a file gets modified during the scan, or perhaps if a file’s encoding leads to incorrect counting of lines. Does this ring any bells with you? In particular:

  • Are you sure the content of the directory doesn’t change during an analysis?
  • Does the error happen always to the same files? (You may need to enable debug logs with -X to see the affected files.)
  • Would you be able to provide a minimal example that reproduces the problem? (For example, ideally, a project with a single file.)