Grails
  1. Grails
  2. GRAILS-8101

org.postgresql.util.PSQLException: No value specified for parameter 1 upon user.save()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0-M2
    • Fix Version/s: 2.3.5
    • Component/s: Persistence
    • Labels:
    • Environment:
      grails-2.0.0.BUILD-SNAPSHOT #1457

      Description

      Hoping to find some cues here, I copy this issue over from StackOverflow (http://stackoverflow.com/questions/7447922/):

      Upon registration to my Grails app, the user receives an email with a confirmation link. Clicking that link, takes her to the according 'enable' action.

      This worked flawlessly. However, there now seems to be an error with a very specific token, which fails the user.save() of this snippet:

      assert !user.isDirty()  // assertion is ok
      user.enabled = true
      user.confirmationToken = null
      assert user.isDirty()   // assertion is ok
      
      if (user.save()) {  // FAILS WITH ERROR BELOW
          // ...
      }
      

      Stacktrace:

      [ 16.09.2011 11:57:47.591] [http-bio-localhost/127.0.0.1-8080-exec-3] 
      ERROR 
      org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver 
      org.apache.commons.logging.impl.SLF4JLog 
      
       Exception occurred when processing request: [GET] /user/enable/bc73701c-d280-4de0-8951-7af9f2a3d636
      Stacktrace follows:
      org.postgresql.util.PSQLException: No value specified for parameter 1.
              at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:178)
              at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:246)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
              at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
              at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
              at myproj.UserService.enableUser(UserService.groovy:234)
              at myproj.UserController$_closure8.doCall(UserController.groovy:244)
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
              at java.lang.Thread.run(Thread.java:619)
      

      Note that I can create additional users in the same running instance - but the error (so far) only occurs with that code.

      Any ideas on how to resolve that?

      Versions in use:

      PostgreSQL: 9.1beta3
      JDBC-driver: postgresql:9.1-901.jdbc4
      Grails: 2.0.0.BUILD-SNAPSHOT (Build #1457)

      (Due to being on development builds for those parts, it might be a bug, but I am unsure about that.)

      1. g8101.tar.bz2
        160 kB
        Bernhard Areich

        Activity

        Hide
        Graeme Rocher added a comment -

        Burt - could you look at this one please

        Show
        Graeme Rocher added a comment - Burt - could you look at this one please
        Hide
        Jason Stonebraker added a comment -

        I can confirm that using the unique: true constraint on the parent class of a one-to-one association results in the "No value specified for parameter 1" error. Removing the unique constraint (recommended in the Grails documentation) resolves the issue.

        http://grails.org/doc/latest/guide/single.html#gormAssociation -> Example C

        Show
        Jason Stonebraker added a comment - I can confirm that using the unique: true constraint on the parent class of a one-to-one association results in the "No value specified for parameter 1" error. Removing the unique constraint (recommended in the Grails documentation) resolves the issue. http://grails.org/doc/latest/guide/single.html#gormAssociation -> Example C
        Hide
        Vladimir Havenchyk added a comment -

        Have same with grails 2.2.4 and mysql db. "No value specified for parameter 1"

        class Book

        { static belongsTo = [author: Author] }

        class Author {

        static hasOne = [book: Book]

        static constraints =

        { book(unique: true) }

        }

        Maybe it is my problem, but removing (unique: true) solves problem

        Show
        Vladimir Havenchyk added a comment - Have same with grails 2.2.4 and mysql db. "No value specified for parameter 1" class Book { static belongsTo = [author: Author] } class Author { static hasOne = [book: Book] static constraints = { book(unique: true) } } Maybe it is my problem, but removing (unique: true) solves problem
        Hide
        Graeme Rocher added a comment -

        I cannot reproduce this with the example application attached and the current version of Grails with either H2 or Postgres configured as a database

        Show
        Graeme Rocher added a comment - I cannot reproduce this with the example application attached and the current version of Grails with either H2 or Postgres configured as a database
        Hide
        Vladimir Havenchyk added a comment -

        But why closed? Graeme, should I create new ticket for this with mysql? 12 up votes, proved examples.

        Show
        Vladimir Havenchyk added a comment - But why closed? Graeme, should I create new ticket for this with mysql? 12 up votes, proved examples.

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Bernhard Areich
          • Votes:
            12 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development