1

我有一个非常流畅的 SonarQube 服务器 v5.3。一切都运行良好。然后今天我决定删除一些我不想要的项目。删除没问题,或者至少我认为是这样。它们从 GUI 中消失了。

我什至检查了数据库,但他们没有显示这个命令:

select * from projects where kee like '%sonar%'

问题是在我删除这些项目后,当我再次尝试运行声纳分析时,只有一个项目是 Provisioned,但分析没有运行。我去的时候得到一个数据库错误

管理 > 后台任务 > 日志

错误是:

2016.05.10 15:59:43 INFO  [o.s.s.c.s.ComputationStepExecutor] Execute component visitors | time=6135ms
2016.05.10 15:59:43 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute measure variations | time=1ms
2016.05.10 15:59:43 INFO  [o.s.s.c.s.ComputationStepExecutor] Computes Quality Gate measures | time=1ms
2016.05.10 15:59:43 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute Quality profile measures | time=18ms
2016.05.10 15:59:43 INFO  [o.s.s.c.s.ComputationStepExecutor] Generate Quality profile events | time=4ms
2016.05.10 15:59:43 INFO  [o.s.s.c.s.ComputationStepExecutor] Generate Quality gate events | time=3ms
2016.05.10 15:59:44 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVSa9zwoeZCFdUKsTOSM
org.sonar.server.computation.component.VisitException: Visit failed for Component {key=com.som.lan:lan-biz:src/main/java/sb1/biz/financing/demo,type=DIRECTORY}  located com.som.lan:lan-biz(type=MODULE)->com.som:lan(type=MODULE)->com.som:modules(type=MODULE)->bm-master_feature_dig-9129-javascript-in-sonar(type=PROJECT)
    at org.sonar.server.computation.component.VisitException.rethrowOrWrap(VisitException.java:44) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visit(PathAwareCrawler.java:52) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visit(PathAwareCrawler.java:50) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visit(PathAwareCrawler.java:50) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visit(PathAwareCrawler.java:50) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.component.PathAwareCrawler.visit(PathAwareCrawler.java:50) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.step.PersistComponentsStep.execute(PersistComponentsStep.java:77) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:39) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.taskprocessor.report.ReportTaskProcessor.process(ReportTaskProcessor.java:72) ~[sonar-server-5.3.jar:na]
    at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.executeTask(CeWorkerCallableImpl.java:81) [sonar-server-5.3.jar:na]
    at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:56) [sonar-server-5.3.jar:na]
    at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:35) [sonar-server-5.3.jar:na]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_72]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_72]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_72]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_72]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_72]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_72]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_72]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_72]
Caused by: org.apache.ibatis.exceptions.PersistenceException:

更新数据库时出错。原因:java.sql.SQLIntegrityConstraintViolationException:ORA-00001:违反了唯一约束(SONAR.PROJECTS_KEE)

错误可能涉及 org.sonar.db.component.ComponentMapper.insert-Inline

设置参数时出错

原因:java.sql.SQLIntegrityConstraintViolationException:ORA-00001:违反了唯一约束(SONAR.PROJECTS_KEE)

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:154) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) ~[mybatis-3.2.7.jar:3.2.7]
at com.sun.proxy.$Proxy64.insert(Unknown Source) ~[na:na]
at org.sonar.db.component.ComponentDao.insert(ComponentDao.java:282) ~[sonar-db-5.3.jar:na]
at org.sonar.server.computation.step.PersistComponentsStep$PersistComponentStepsVisitor.persistComponent(PersistComponentsStep.java:172) ~[sonar-server-5.3.jar:na]
at org.sonar.server.computation.step.PersistComponentsStep$PersistComponentStepsVisitor.persistAndPopulateCache(PersistComponentsStep.java:164) ~[sonar-server-5.3.jar:na]
at org.sonar.server.computation.step.PersistComponentsStep$PersistComponentStepsVisitor.visitDirectory(PersistComponentsStep.java:136) ~[sonar-server-5.3.jar:na]
at org.sonar.server.computation.component.PathAwareCrawler.visitNode(PathAwareCrawler.java:102) ~[sonar-server-5.3.jar:na]
at org.sonar.server.computation.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:67) ~[sonar-server-5.3.jar:na]
at org.sonar.server.computation.component.PathAwareCrawler.visit(PathAwareCrawler.java:50) ~[sonar-server-5.3.jar:na]
... 26 common frames omitted

引起:java.sql.SQLIntegrityConstraintViolationException:ORA-00001:违反了唯一约束(SONAR.PROJECTS_KEE)

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:208) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1046) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3613) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3714) ~[ojdbc6.jar:11.2.0.4.0]
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1378) ~[ojdbc6.jar:11.2.0.4.0]
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) ~[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) ~[commons-dbcp-1.4.jar:1.4]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:50) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71) ~[mybatis-3.2.7.jar:3.2.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152) ~[mybatis-3.2.7.jar:3.2.7]
... 37 common frames omitted

2016.05.10 15:59:44 错误 [ossctCeWorkerCallableImpl] 执行任务 | 项目=bm-master_feature_dig-9129-javascript-in-sonar | id=AVSa9zwoeZCFdUKsTOSM | 时间=8689ms

无论项目名称如何,都会显示此错误。似乎是模块导致了唯一约束,而不是项目名称本身。

我努力了:

  • 使用 GUI 删除项目
  • 停止声纳并重新启动

除了查看表格以查看是否可以解决问题之外,我没有在数据库中手动执行任何操作。

知道我怎么能摆脱这个吗?

谢谢 :)

编辑:

我正在像这样使用 Maven 运行声纳:

mvn -e sonar:sonar \
-DskipTests \
-DXmx2g \
-DXX:MaxPermSize=1g \
-Dsonar.host.url=http://sonar.myserver.com \
-Dsonar.projectKey=${sonarProjectName} \
-Dsonar.projectName=${sonarProjectName} \
-Dsonar.projectVersion=${branch} \
-Dsonar.forceAnalysis=true \
-Dsonar.sourceEncoding=UTF-8 \
-Dmaven.test.failure.ignore=true \
-Dsonar.sources=. \
-Dsonar.exclusions=**/target/**/*,**/src/lib/**/*,**/node_modules/**/* \
-Dsonar.test.exclusions=**/src/test/java/** \
-Dsonar.junit.reportsPath=**/target/surefire-reports \
-Dsonar.jacoco.reportPath=${WORKSPACE}/target/jacoco.exec \
-Dsonar.jacoco.itReportPath=${WORKSPACE}/target/jacoco-it.exec \
-Dsonar.java.binaries=**/target/classes \
-Dsonar.java.coveragePlugin=jacoco \
-Dsonar.verbose=true

由于这里 IT 设置的性质,我不能使用 Jenkins SonarQube Runner 插件。我在这里的另一个项目中使用它,它运行完美。

4

1 回答 1

0

我解决了这个问题,但我不知道为什么问题首先发生。

解决方案是排除 src 演示目录,所以我将排除项更改为:

    -Dsonar.exclusions=**/target/**/*,**/src/lib/**/*,**/node_modules/**/*,**/src/main/java/**/demo/**/* \

我不确定为什么会出现错误。后来我在我的声纳主机上查看管理 GUI,我在管理 > 常规设置 > 分析范围 > 我已经拥有的文件下看到

**/demo/*.java

作为源文件排除。

我想知道这是否是导致唯一约束错误的原因?无论如何,我希望我能得到比这更好的回应,所以我知道为什么会发生错误。

于 2016-05-11T09:09:22.050 回答