Sonar

Exception : javax.persistence.NonUniqueResultException due to case sensitivity.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.11
  • Fix Version/s: None
  • Component/s: Database
  • Labels:
    None
  • Environment:
    We are using Hudson 1.323 and Sonar 1.11.
  • Number of attachments :
    3

Description

Since we updated to sonar 1.11 we get this exception during our hudson build...

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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:87)
at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:65)
at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:117)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: javax.persistence.NonUniqueResultException: result returns more than one elements
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:109)
at org.sonar.api.database.DatabaseSession.getSingleResult(DatabaseSession.java:161)
at org.sonar.api.database.DatabaseSession.getSingleResult(DatabaseSession.java:174)
at org.sonar.batch.DefaultSensorContext.createResource(DefaultSensorContext.java:317)
at org.sonar.batch.DefaultSensorContext.saveSnapshot(DefaultSensorContext.java:304)
at org.sonar.batch.DefaultSensorContext.saveSource(DefaultSensorContext.java:194)
at org.sonar.api.batch.AbstractSourceImporter.parseDirs(AbstractSourceImporter.java:80)
at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:71)
at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:63)
at org.sonar.batch.core.SensorsExecutor.execute(SensorsExecutor.java:59)
at org.sonar.batch.Batch.executeJobs(Batch.java:91)
at org.sonar.batch.Batch.analyse(Batch.java:79)
at org.sonar.batch.Batch.start(Batch.java:54)
at org.sonar.batch.BatchMojo.executeBatch(BatchMojo.java:138)
at org.sonar.batch.BatchMojo.execute(BatchMojo.java:130)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:82)
... 21 more

Activity

Hide
Cyrille Lebec added a comment -

The issue is not due to the same problem describe in the SONAR-1197.

As resultset for the query

select * from projects where kee = 'com.lodh.webservices.web-portfolio:web-portfolio-portfolio:com.lodh.portfolio.explorer'

i get :

+------+-----------------------------+-------------+---------+-------+-----------+----------------------------------------------------------------------------------------+---------+------------+----------+------------------+
| id   | name                        | description | enabled | scope | qualifier | kee                                                                                    | root_id | profile_id | language | copy_resource_id |
+------+-----------------------------+-------------+---------+-------+-----------+----------------------------------------------------------------------------------------+---------+------------+----------+------------------+
| 494  | Explorer                    | NULL        |       1 | FIL   | CLA       | com.lodh.webservices.web-portfolio:web-portfolio-portfolio:com.lodh.portfolio.Explorer |    30   |       NULL | java     |             NULL | 
| 4402 | com.lodh.portfolio.explorer | NULL        |       1 | DIR   | PAC       | com.lodh.webservices.web-portfolio:web-portfolio-portfolio:com.lodh.portfolio.explorer |    30   |       NULL | java     |             NULL | 
+------+-----------------------------+-------------+---------+-------+-----------+----------------------------------------------------------------------------------------+---------+------------+----------+------------------+

So it seem that the problem in my case is due to case sensitivity.

can you please help on this issue.

Show
Cyrille Lebec added a comment - The issue is not due to the same problem describe in the SONAR-1197. As resultset for the query
select * from projects where kee = 'com.lodh.webservices.web-portfolio:web-portfolio-portfolio:com.lodh.portfolio.explorer'
i get :
+------+-----------------------------+-------------+---------+-------+-----------+----------------------------------------------------------------------------------------+---------+------------+----------+------------------+
| id   | name                        | description | enabled | scope | qualifier | kee                                                                                    | root_id | profile_id | language | copy_resource_id |
+------+-----------------------------+-------------+---------+-------+-----------+----------------------------------------------------------------------------------------+---------+------------+----------+------------------+
| 494  | Explorer                    | NULL        |       1 | FIL   | CLA       | com.lodh.webservices.web-portfolio:web-portfolio-portfolio:com.lodh.portfolio.Explorer |    30   |       NULL | java     |             NULL | 
| 4402 | com.lodh.portfolio.explorer | NULL        |       1 | DIR   | PAC       | com.lodh.webservices.web-portfolio:web-portfolio-portfolio:com.lodh.portfolio.explorer |    30   |       NULL | java     |             NULL | 
+------+-----------------------------+-------------+---------+-------+-----------+----------------------------------------------------------------------------------------+---------+------------+----------+------------------+
So it seem that the problem in my case is due to case sensitivity. can you please help on this issue.
Hide
Simon Brandhof added a comment -

Hi Cyrille,
Which database do you use ?

Show
Simon Brandhof added a comment - Hi Cyrille, Which database do you use ?
Hide
Cyrille Lebec added a comment -

Hi simon,
The databse is MySQL 5.0.41.

Show
Cyrille Lebec added a comment - Hi simon, The databse is MySQL 5.0.41.
Hide
Simon Brandhof added a comment -

FYI I can't reproduce the issue on MySql 5.1.
Can you try to activate the flag 'binary' on the column PROJECTS.KEE ? It should force the column to be case-sensitive.

Show
Simon Brandhof added a comment - FYI I can't reproduce the issue on MySql 5.1. Can you try to activate the flag 'binary' on the column PROJECTS.KEE ? It should force the column to be case-sensitive.
Hide
Cyrille Lebec added a comment -

Activating the flag "binary" on that column fix the issue.
Thanks,

Is this flag activated by default in the last schema of the database of sonar...
If yes, maybe the flag update was missing in one of the upgrade path from a very old version as my installation of sonar follows all the version since the first beta.

You can resolve and close the issue, all is in order for me.
Long life to Sonar and regards to Freddy.

Show
Cyrille Lebec added a comment - Activating the flag "binary" on that column fix the issue. Thanks, Is this flag activated by default in the last schema of the database of sonar... If yes, maybe the flag update was missing in one of the upgrade path from a very old version as my installation of sonar follows all the version since the first beta. You can resolve and close the issue, all is in order for me. Long life to Sonar and regards to Freddy.
Hide
Ben Tatham added a comment -

Can someone tell me how to active this 'binary' flag from mysql command console? (google is doing a surprisingly bad job at finding this)

Show
Ben Tatham added a comment - Can someone tell me how to active this 'binary' flag from mysql command console? (google is doing a surprisingly bad job at finding this)
Hide
Olivier Gaudin added a comment -

Go to MySQL Administrator -> Catalogs -> Choose Schema -> Double click on the table. You can then change the flag.

Show
Olivier Gaudin added a comment - Go to MySQL Administrator -> Catalogs -> Choose Schema -> Double click on the table. You can then change the flag.
Hide
Simon Brandhof added a comment -

Hi Ben, do you confirm that you also use a MySql 5.0 version, not 5.1 ?

Show
Simon Brandhof added a comment - Hi Ben, do you confirm that you also use a MySql 5.0 version, not 5.1 ?
Hide
Ben Tatham added a comment -

We are using MySql 5.0.45.
This seems to have fixed the problem (and I cleaned up the rest of our issues, based on the select/deletes described in Bug 1197).
I think all our projects are running properly again.

Why did the problem just start occurring for us? Is it caused by the big migration from 1.9 to 1.11?

Show
Ben Tatham added a comment - We are using MySql 5.0.45. This seems to have fixed the problem (and I cleaned up the rest of our issues, based on the select/deletes described in Bug 1197). I think all our projects are running properly again. Why did the problem just start occurring for us? Is it caused by the big migration from 1.9 to 1.11?
Hide
Olivier Gaudin added a comment -

Cyrille and Ben, could you give me some more information to try to dig into the issue a bit deeper ?

Ben, can you try to run the select that Cyrille ran without the binary flag and see if returns the same thing ?
Cyrille, can you tell me what was the version you started the migration from ?

Both, can you attach a screenshot of the projects table definition in mysql administrator ? I would be interested to get as well is what you have in Startup Variables, advanced tab in the Localization section.
Could you confirm as well that those duplicated objects existed in prior versions of Sonar ?

Show
Olivier Gaudin added a comment - Cyrille and Ben, could you give me some more information to try to dig into the issue a bit deeper ? Ben, can you try to run the select that Cyrille ran without the binary flag and see if returns the same thing ? Cyrille, can you tell me what was the version you started the migration from ? Both, can you attach a screenshot of the projects table definition in mysql administrator ? I would be interested to get as well is what you have in Startup Variables, advanced tab in the Localization section. Could you confirm as well that those duplicated objects existed in prior versions of Sonar ?
Hide
Cyrille Lebec added a comment -

Hi Olivier,

I update sonar from the 1.10.1 version but as written before, my installation follows all the version of sonar since the first beta.
I also confirm that thoses duplicated objects existed before this version and the build was working fine, even in 1.10.1.

I've attached the Localization startup variables (see "cyrille_localization_startup_variables").. but can you be more precise on what you expect when you ask for "a screenshot of the projects table definition in mysql administrator". Do you mean for each tables, the "MySql Table Editor" screen retrieved whern you double-click on a table in the "schema Tables" screen ?

Show
Cyrille Lebec added a comment - Hi Olivier, I update sonar from the 1.10.1 version but as written before, my installation follows all the version of sonar since the first beta. I also confirm that thoses duplicated objects existed before this version and the build was working fine, even in 1.10.1. I've attached the Localization startup variables (see "cyrille_localization_startup_variables").. but can you be more precise on what you expect when you ask for "a screenshot of the projects table definition in mysql administrator". Do you mean for each tables, the "MySql Table Editor" screen retrieved whern you double-click on a table in the "schema Tables" screen ?
Hide
Olivier Gaudin added a comment -

I meant the definition of the table "Projects".

Show
Olivier Gaudin added a comment - I meant the definition of the table "Projects".
Hide
Cyrille Lebec added a comment -

Hi Olivier,
Just upload my screenshot for the "projects" table..

The "binary" flag has been set manually as ask by Simon for fixing this issue.

Show
Cyrille Lebec added a comment - Hi Olivier, Just upload my screenshot for the "projects" table.. The "binary" flag has been set manually as ask by Simon for fixing this issue.
Hide
Olivier Gaudin added a comment -

Cyrille, thank you very much for the information. I did not manage to reproduce the issue and as there is a work around, I am going to close the ticket.

Show
Olivier Gaudin added a comment - Cyrille, thank you very much for the information. I did not manage to reproduce the issue and as there is a work around, I am going to close the ticket.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: