VisitException: Visit failed for Component (Community Edition v9.4)

We are using SonarQube Community Edition Version 9.4 (build 54424). It is running locally in a Docker container. The project is .NET 6

The command to trigger a scan is:

dotnet sonarscanner begin /k:$solution /v:$version /d:sonar.host.url=http://localhost:9000 /d:sonar.cs.opencover.reportsPaths="\test\*.Tests\coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests*.cs,**/*.js"

The first time running a scan is successful, but then every scan afterwards fails with the following error:

The Project Analysis has failed.

We have tried (none of which change the outcome):

  • Switching branches
  • Using master branch
  • Build release
org.sonar.ce.task.projectanalysis.component.VisitException: Visit failed for Component {key=REDACTED/coverage.opencover.xml,type=FILE}  located REDACTED(type=DIRECTORY)->REDACTED(type=DIRECTORY)->REDACTED(type=PROJECT)
	at org.sonar.ce.task.projectanalysis.component.VisitException.rethrowOrWrap(VisitException.java:44)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:52)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:50)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:50)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:50)
	at org.sonar.ce.task.projectanalysis.step.NewCoverageMeasuresStep.execute(NewCoverageMeasuresStep.java:90)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeStep(ComputationStepExecutor.java:80)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:71)
	at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:58)
	at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:75)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:212)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:194)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:160)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalStateException: Fail to read FILE_SOURCES.LINE_HASHES of file AYDgOre-0d202zMCfCzW
	at org.sonar.db.source.FileSourceDao.selectLineHashes(FileSourceDao.java:71)
	at org.sonar.ce.task.projectanalysis.source.SourceLinesDiffImpl.getDBLines(SourceLinesDiffImpl.java:84)
	at org.sonar.ce.task.projectanalysis.source.SourceLinesDiffImpl.computeMatchingLines(SourceLinesDiffImpl.java:62)
	at org.sonar.ce.task.projectanalysis.scm.ScmInfoRepositoryImpl.generateAndMergeDb(ScmInfoRepositoryImpl.java:128)
	at org.sonar.ce.task.projectanalysis.scm.ScmInfoRepositoryImpl.getScmInfoForComponent(ScmInfoRepositoryImpl.java:75)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
	at org.sonar.ce.task.projectanalysis.scm.ScmInfoRepositoryImpl.getScmInfo(ScmInfoRepositoryImpl.java:66)
	at org.sonar.ce.task.projectanalysis.source.NewLinesRepository.computeNewLinesFromScm(NewLinesRepository.java:72)
	at org.sonar.ce.task.projectanalysis.source.NewLinesRepository.getNewLines(NewLinesRepository.java:64)
	at org.sonar.ce.task.projectanalysis.step.NewCoverageMeasuresStep$NewCoverageCounter.initialize(NewCoverageMeasuresStep.java:205)
	at org.sonar.ce.task.projectanalysis.formula.FormulaExecutorComponentVisitor.processLeaf(FormulaExecutorComponentVisitor.java:148)
	at org.sonar.ce.task.projectanalysis.formula.FormulaExecutorComponentVisitor.process(FormulaExecutorComponentVisitor.java:125)
	at org.sonar.ce.task.projectanalysis.formula.FormulaExecutorComponentVisitor.visitFile(FormulaExecutorComponentVisitor.java:105)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitNode(PathAwareCrawler.java:102)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:73)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:50)
	... 29 more
Caused by: org.h2.jdbc.JdbcSQLDataException: Value too long for column "CHARACTER VARYING": "9c01c303c77851bb36f0a499a6d66d41\000ad9178d6a5ba66b643fce6eb73edce711\000a739897801b231d... (1242350)" [22001-210]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:525)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
	at org.h2.message.DbException.get(DbException.java:227)
	at org.h2.message.DbException.getValueTooLongException(DbException.java:341)
	at org.h2.value.ValueLob.getStringTooLong(ValueLob.java:192)
	at org.h2.value.ValueClob.getString(ValueClob.java:169)
	at org.h2.jdbc.JdbcResultSet.getString(JdbcResultSet.java:283)
	at org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:888)
	at org.apache.commons.dbcp2.DelegatingResultSet.getString(DelegatingResultSet.java:888)
	at org.sonar.db.source.FileSourceDao.selectLineHashes(FileSourceDao.java:63)
	... 44 more

I wonder if the true error is:

JdbcSQLDataException: Value too long for column "CHARACTER VARYING"

…but then how can this be solved?

Hey there.

We’ve seen some similar problem reports:

It typically boils down to:

  • The embedded H2 database being used (which is not meant for production use)
  • A very large file being indexed

How large is the file (either by file size for Lines of Code) that is mentioned in the error?

In any case since this in an XML coverage report (I’m not sure why it is being indexed in the first place), you could probably add an exclusion and be on your way.

/d:sonar.exclusions=**/coverage.opencover.xml

The Scanner for .NET relies on the .csproj files in a project to direct it to which files it should analyze. Perhaps you have a very wide inclusion for XML files? See the documentation on Advanced Topics > Analyzing languages other than C# and VB

Thanks Colin for the reply.

I actually found that because a sequence of commands are being executed from a script, there was a command that when executed outside of scope caused this error.

So the original script looked like this:

Write-Host "Run the tests`r`n"
dotnet test ("{0}.sln" -f $solution) --collect:"XPlat Code Coverage" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

Write-Host "Stop the build server`r`n"
dotnet build-server shutdown

Write-Host "Start the scanner`r`n"
dotnet sonarscanner begin /k:$solution /v:$version /d:sonar.host.url=http://localhost:9000 /d:sonar.cs.opencover.reportsPaths="\test\*.Tests\coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests*.cs,**/*.js"

Write-Host "Build the solution`r`n"
dotnet build ("{0}.sln" -f $solution)

Write-Host "Stop the scanner`r`n"
dotnet sonarscanner end

:point_right:The solution was to move “dotnet test” to after the build step (between begin and end):

Write-Host "Stop the build server`r`n"
dotnet build-server shutdown

Write-Host "Start the scanner`r`n"
dotnet sonarscanner begin /k:$solution /v:$version /d:sonar.host.url=http://localhost:9000 /d:sonar.cs.opencover.reportsPaths="\test\*.Tests\coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests*.cs,**/*.js"

Write-Host "Build the solution`r`n"
dotnet build ("{0}.sln" -f $solution)

Write-Host "Run the tests`r`n"
dotnet test ("{0}.sln" -f $solution) --collect:"XPlat Code Coverage" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

Write-Host "Stop the scanner`r`n"
dotnet sonarscanner end

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.