Grails
  1. Grails
  2. GRAILS-8784

Wrong Compilation behavior for a Command class inside a Controller class file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: Build System
    • Labels:
      None
    • Environment:
      Grails 2.0.1, Java 1.6, Windows XP

      Description

      There are 2 wrong behaviours.

      1) First, just try to "run-app" for this attached example. You'll get this message:

      Error Compilation error: startup failed:
      D:\grails\grails-app\controllers\bug\SearchController.groovy: Controller actions may not be overloaded. The [compareTo] action has been overloaded in [bug.SearchCommand].

      2) Change all references to "private int compareTo(def main, def other)" to "private int compareTo2(def main, def other)" and try to "run-app" again. You'll get this message:

      Warning The [toUrlParams] action in [bug.SearchCommand] accepts a parameter of type [bug.enums.Group] which has not been marked with @grails.validation.Validateable. This may lead to an intermittent MissingMethodException for validate(). We strongly recommend that you mark command object classes with @Validateable in order to avoid the problem.

      String toUrlParams(Group group) {
      ^

      Compiling 11 source files.
      Error Compilation error: startup failed:
      D:\grails\grails-app\controllers\bug\SearchController.groovy: -1: Enum constructor calls are only allowed inside the enum class
      . At [-1:-1] @ line -1, column -1.
      1 error

        Activity

        Hide
        Oleg Migrin added a comment -

        Have the same problem

        Show
        Oleg Migrin added a comment - Have the same problem
        Hide
        Jeff Scott Brown added a comment -

        Oleg,

        I believe that we fixed this several weeks ago and the fix should be included in Grails 2.0.2 (which will be released very soon). If you are interested in helping to verify the fix, please grab a snapshot build from http://hudson.grails.org/view/Grails%202.0.x/job/grails_core_2.0.x/lastSuccessfulBuild/artifact/build/distributions/ and give it a spin. If you do, please comment here with the outcome of that.

        Thanks.

        Show
        Jeff Scott Brown added a comment - Oleg, I believe that we fixed this several weeks ago and the fix should be included in Grails 2.0.2 (which will be released very soon). If you are interested in helping to verify the fix, please grab a snapshot build from http://hudson.grails.org/view/Grails%202.0.x/job/grails_core_2.0.x/lastSuccessfulBuild/artifact/build/distributions/ and give it a spin. If you do, please comment here with the outcome of that. Thanks.
        Hide
        Vasu Srinivasan added a comment -

        I was able to simulate this error in a similar scenario (without any command objects) in Grails 2.0.1.

        "...action accepts a parameter of type [java.io.File] which does not appear to be a command object class. Command object must be marked with @Validateable".

        class MyController {

        //....
        def list() {
        File[] f = new File("c:/mydirectory/").listFiles(
        new FilenameFilter() {
        boolean accept(File dir, String name)

        { return name.endsWith("txt") }

        }
        )
        f.each

        { println it.fileName }

        }
        }

        I tried in Grails 2.0.3 and the error is not there anymore.

        Show
        Vasu Srinivasan added a comment - I was able to simulate this error in a similar scenario (without any command objects) in Grails 2.0.1. "...action accepts a parameter of type [java.io.File] which does not appear to be a command object class. Command object must be marked with @Validateable". class MyController { //.... def list() { File[] f = new File("c:/mydirectory/").listFiles( new FilenameFilter() { boolean accept(File dir, String name) { return name.endsWith("txt") } } ) f.each { println it.fileName } } } I tried in Grails 2.0.3 and the error is not there anymore.

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            André Mattos
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development