Sonar:删除旧项目后无法处理新项目

Sonar: Cannot process new projects after deletion of an old project

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

我什至已经检查过数据库,但他们没有使用这个命令显示:

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

问题是我删除了这些项目后,当我再次尝试运行声纳分析时,一个项目只提供了,但分析没有运行。当我转到

时出现数据库错误

管理 > 后台任务 > 日志

错误是:

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.access1(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 错误 [o.s.s.c.t.CeWorkerCallableImpl] 已执行任务 |项目=bm-master_feature_dig-9129-javascript-in-sonar | id=AVSa9zwoeZCFdUKsTOSM |时间=8689ms

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

我试过:

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

知道如何摆脱它吗?

谢谢:)

编辑:

我正在 运行ning sonar with 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 插件。我在这里的另一个项目中使用了它并且它 运行 完美无缺。

我解决了这个问题,但我不知道为什么会出现这个问题。

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

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

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

**/demo/*.java

作为源文件排除项。

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