2012-06-11 77 views
2

我使用聲吶與maven來分析項目(包括php和java)。最近在掃描一些項目時,Sonar會顯示如下錯誤消息:聲吶在使用maven分析時顯示錯誤消息

+ Error stacktraces are turned on. 
[INFO] Scanning for projects... 
[INFO] Searching repository for plugin with prefix: 'sonar'. 
[INFO] Ignoring available plugin update: 2.0 as it requires Maven version 3.0 
[INFO] Ignoring available plugin update: 2.0-beta-2 as it requires Maven version 3.0 
[INFO] Ignoring available plugin update: 2.0-beta-1 as it requires Maven version 3.0 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building java 
[INFO] task-segment: [sonar:sonar] (aggregator-style) 
[INFO] ------------------------------------------------------------------------ 
[INFO] [sonar:sonar {execution: default-cli}] 
[INFO] Sonar host: http://localhost:9000 
[INFO] Sonar version: 2.14 
[INFO] Execute: org.codehaus.sonar:sonar-maven-plugin:2.14:sonar 
[INFO] [sonar:sonar {execution: default-sonar}] 
[WARN] [17:40:35.282] Derby database should be used for evaluation purpose only 
[INFO] [17:40:35.298] Create JDBC datasource 
[INFO] [17:40:36.757] Initializing Hibernate 
[INFO] [17:40:41.233] ------------- Analyzing java 
[INFO] [17:40:42.858] Selected quality profile : [name=Sonar way,language=java] 
[INFO] [17:40:42.969] Configure maven plugins... 
[INFO] [17:40:43.248] Compare to previous analysis (2012-06-06) 
[INFO] [17:40:43.309] Compare over 5 days (2012-06-06, analysis of 2012-06-06 16:36:01.996) 
[INFO] [17:40:43.336] Compare over 30 days (2012-05-12, analysis of 2012-05-30 17:05:04.248) 
[INFO] [17:40:43.455] Initializer FindbugsMavenInitializer... 
[INFO] [17:40:43.466] Initializer FindbugsMavenInitializer done: 11 ms 
[INFO] [17:40:43.466] Initializer ProjectFileSystemLogger... 
[INFO] [17:40:43.471] Source directories: 
[INFO] [17:40:43.471] /home/gamer/NetBeansProjects/QE 
[INFO] [17:40:43.473] Initializer ProjectFileSystemLogger done: 7 ms 
[INFO] [17:40:43.473] Initializer MavenInitializer... 
[INFO] [17:40:43.476] Java source version: 1.5 
[INFO] [17:40:43.476] Java target version: 1.5 
[INFO] [17:40:43.476] Source encoding: null 
[INFO] [17:40:43.476] Initializer MavenInitializer done: 3 ms 
[INFO] [17:40:43.514] Sensor JavaSourceImporter... 
[WARN] [17:40:43.552] SQL Error: -1, SQLState: 23505 
[ERROR] [17:40:43.552] The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL110927104436930' defined on 'PROJECTS'. 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Can not execute Sonar 

Embedded error: Unable to read and import the source file : '/home/gamer/NetBeansProjects/QE/src/QEmain/QE_main.java' with the charset : 'UTF-8'. 
The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL110927104436930' defined on 'PROJECTS'. 
[INFO] ------------------------------------------------------------------------ 
[INFO] Trace 
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar 
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719) 
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569) 
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539) 
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) 
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284) 
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) 
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) 
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) 
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) 
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375) 
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar 
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:103) 
    at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:79) 
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:88) 
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) 
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) 
    ... 17 more 
Caused by: org.sonar.api.utils.SonarException: Unable to read and import the source file : '/home/gamer/NetBeansProjects/QE/src/QEmain/QE_main.java' with the charset : 'UTF-8'. 
    at org.sonar.plugins.squid.JavaSourceImporter.importSource(JavaSourceImporter.java:87) 
    at org.sonar.plugins.squid.JavaSourceImporter.parseDirs(JavaSourceImporter.java:73) 
    at org.sonar.plugins.squid.JavaSourceImporter.analyse(JavaSourceImporter.java:66) 
    at org.sonar.plugins.squid.JavaSourceImporter.analyse(JavaSourceImporter.java:62) 
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64) 
    at org.sonar.batch.phases.Phases.execute(Phases.java:93) 
    at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:143) 
    at org.sonar.batch.bootstrap.Module.start(Module.java:83) 
    at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:115) 
    at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:105) 
    at org.sonar.batch.bootstrap.Module.start(Module.java:83) 
    at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:102) 
    at org.sonar.batch.bootstrap.Module.start(Module.java:83) 
    at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:71) 
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:58) 
    at org.sonar.maven.SonarMojo.execute(SonarMojo.java:151) 
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) 
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:98) 
    ... 21 more 
Caused by: javax.persistence.PersistenceException: Unable to persist : [email protected][id=<null>,key=qb:artid:src.QEmain,scope=DIR,qualifier=PAC,name=src.QEmain,longName=src.QEmain,lang=java,enabled=true,rootId=1095,copyResourceId=<null>,personId=<null>] 
    at org.sonar.jpa.session.JpaDatabaseSession.internalSave(JpaDatabaseSession.java:119) 
    at org.sonar.jpa.session.JpaDatabaseSession.save(JpaDatabaseSession.java:89) 
    at org.sonar.batch.index.DefaultResourcePersister.persistFileOrDirectory(DefaultResourcePersister.java:184) 
    at org.sonar.batch.index.DefaultResourcePersister.persist(DefaultResourcePersister.java:132) 
    at org.sonar.batch.index.DefaultResourcePersister.saveResource(DefaultResourcePersister.java:115) 
    at org.sonar.batch.index.DefaultPersistenceManager.saveResource(DefaultPersistenceManager.java:72) 
    at org.sonar.batch.index.DefaultIndex.doIndex(DefaultIndex.java:513) 
    at org.sonar.batch.index.DefaultIndex.doIndex(DefaultIndex.java:479) 
    at org.sonar.batch.index.DefaultIndex.doIndex(DefaultIndex.java:477) 
    at org.sonar.batch.index.DefaultIndex.index(DefaultIndex.java:471) 
    at org.sonar.batch.DefaultSensorContext.index(DefaultSensorContext.java:54) 
    at org.sonar.plugins.squid.JavaSourceImporter.importSource(JavaSourceImporter.java:79) 
    ... 38 more 
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert: [org.sonar.api.database.model.ResourceModel] 
    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) 
    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226) 
    at org.sonar.jpa.session.JpaDatabaseSession.internalSave(JpaDatabaseSession.java:113) 
    ... 49 more 
Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [org.sonar.api.database.model.ResourceModel] 
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94) 
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) 
    at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:64) 
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176) 
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656) 
    at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71) 
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) 
    at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321) 
    at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204) 
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130) 
    at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49) 
    at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154) 
    at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110) 
    at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61) 
    at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:646) 
    at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:620) 
    at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:624) 
    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220) 
    ... 50 more 
Caused by: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL110927104436930' defined on 'PROJECTS'. 
    at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source) 
    at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source) 
    at org.apache.derby.client.am.PreparedStatement.executeUpdate(Unknown Source) 
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
    at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57) 
    ... 65 more 
Caused by: org.apache.derby.client.am.SqlException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL110927104436930' defined on 'PROJECTS'. 
    at org.apache.derby.client.am.Statement.completeExecute(Unknown Source) 
    at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source) 
    at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source) 
    at org.apache.derby.client.net.StatementReply.readExecute(Unknown Source) 
    at org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown Source) 
    at org.apache.derby.client.am.PreparedStatement.readExecute(Unknown Source) 
    at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source) 
    at org.apache.derby.client.am.PreparedStatement.executeUpdateX(Unknown Source) 
    ... 69 more 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 13 seconds 
[INFO] Finished at: Mon Jun 11 17:40:43 IST 2012 
[INFO] Final Memory: 22M/178M 
[INFO] ------------------------------------------------------------------------ 

有人能幫我理解這個錯誤信息嗎?我該如何糾正這個錯誤? Google沒有返回結果。

回答

1

您的問題與您的項目配置有關聯。該信息具有誤導性(Sonar 3.0 gives a clearer message)。這個問題的根本原因是Sonar嘗試創建2個具有相同密鑰的資源:「qb:artid:src.QEmain」。所以這可能意味着你有多個源目錄和相同的「src/QEmain」文件夾。