Quantcast

Grails 2.0.1 strange behaviour

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Grails 2.0.1 strange behaviour

ACMattos
Hi All,

I´m testing my Grails 1.3.7 application under 2.0.1 core. I got 2 compilation problems. First, let me explain the how components are disposed:
1) controller: package.SearchController.groovy
2) command:package.SearchCommand (inside SearchController.groovy file) 
3) enum: package.enums.Group.groovy
 
The first error i got was the compiler complaining about a "compareTo" method. I have one compareTo overridden from Object class and a second one overloaded. Both methods were in "SearchCommand" class. To get rid off this message I just chanced the name of overloaded method to "compareTo2".
 
Then a second error came:
 
"Error Compilation error: startup failed:
D:\app\grails-app\controllers\package\SearchController.groovy: The [toUrlParams] action accepts a parameter of type [package.enums.Group] which does not appear to be a command object class.  This can happen if the source code for this class is not in this project and the class is not marked with @Validateable.
"
 
Group is a simple enum and "toUrlParams" is just a simple helper method of SearchCommand object (written on the same file of SearchController.groovy). To get rid of this message, I had to put "SearchCommand" in its on file.
 
I think it´s a strange behaviour. But was surprised to see no complaining while compiling when I decided to revert method "compareTo2" to "compareTo" againg. I think there is a kind of bug situation here.
 
Thanks,
 
ACMattos.
 
 
1) I´m trying to run my 1.3.7 app into 2.0.1 grails environment. I´m
experiencing some compilation problems. This is the compilation
message:
| Error Compilation error: startup failed:
D:\app\grails-app\controllers\package\SearchController.groovy: The
[toUrlParams] action accepts a parameter of type [package.enums.Group]
which does not appear to be a command object class.  This can happen
if the source code for this class is not in this project and the class
is not marked with @Validateable.
Group is a simple enum and "toUrlParams" is just a simple helper
method of SearchCommand object (written on the same file of
SearchController.groovy). What´s is different in Grails 2.0.1 that
causes this failure? What should I do to fix this?


 
On Wed, Feb 15, 2012 at 10:28 AM, Graeme Rocher <[hidden email]> wrote:
That is part of the maven plugin and not Grails, which has not been
released yet and still requires some work. Hopefully it will be ready
in the next few days

Cheers

On Wed, Feb 15, 2012 at 1:10 PM, furtivechris <[hidden email]> wrote:
> That fixed crud and resources, but its still complaining about
> grails-dependencies (not sure if this is just a construct for consolidating
> other dependencies and whether its still needed for 2.0.1...?)
>                ::::::::::::::::::::::::::::::::::::::::::::::
>                ::          UNRESOLVED DEPENDENCIES         ::
>                ::::::::::::::::::::::::::::::::::::::::::::::
>                :: org.grails#grails-dependencies;2.0.1: not found
>                ::::::::::::::::::::::::::::::::::::::::::::::
>
>
> Graeme Rocher-4 wrote
>>
>> Sorry, ran the wrong command in the build (uploadArchives instead of
>> uploadPublished). Please try now
>>
>> Thanks
>>
>> On Wed, Feb 15, 2012 at 12:29 PM, furtivechris &lt;cbgrails@&gt; wrote:
>>> Strange, I can't see them through the artifactory web front end, and
>>> getting
>>> following trying to build:
>>>                ::::::::::::::::::::::::::::::::::::::::::::::
>>>                ::          UNRESOLVED DEPENDENCIES         ::
>>>                ::::::::::::::::::::::::::::::::::::::::::::::
>>>                :: org.grails#grails-crud;2.0.1: not found
>>>                :: org.grails#grails-dependencies;2.0.1: not found
>>>                :: org.grails#grails-resources;2.0.1: not found
>>>                ::::::::::::::::::::::::::::::::::::::::::::::
>>>
>>>
>>> -----
>>> Chris.
>>> http://squadpoint.com
>>> http://fabgirlfitness.com
>>> --
>>> View this message in context:
>>> http://grails.1312388.n4.nabble.com/Grails-2-0-1-Released-tp4387687p4390114.html
>>> Sent from the Grails - user mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>>
>>
>> --
>> Graeme Rocher
>> Grails Project Lead
>> SpringSource - A Division of VMware
>> http://www.springsource.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>
>
> -----
> Chris.
> http://squadpoint.com
> http://fabgirlfitness.com
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Grails-2-0-1-Released-tp4387687p4390189.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails 2.0.1 strange behaviour

Jeff Brown-3
On Wed, Feb 15, 2012 at 7:27 AM, ACMattos <[hidden email]> wrote:

>
> Then a second error came:
>
> "Error Compilation error: startup failed:
> D:\app\grails-app\controllers\package\SearchController.groovy: The
> [toUrlParams] action accepts a parameter of type [package.enums.Group] which
> does not appear to be a command object class.  This can happen if the source
> code for this class is not in this project and the class is not marked with
> @Validateable."
>
> Group is a simple enum and "toUrlParams" is just a simple helper method of
> SearchCommand object (written on the same file of SearchController.groovy).
> To get rid of this message, I had to put "SearchCommand" in its on file.
>

That does not sound right.  The error message suggests that the
toUrlParams method is defined in the controller.  Your note says that
it is defined in SearchCommand.  Are you sure that is correct?

In Grails 2, all public methods defined in a controller are treated as
controller actions.  If you have a helper method, it should not be
public.



jb
--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails 2.0.1 strange behaviour

ACMattos
Hi Jeff,

Thanks for your time. :-)

The code is quite simple:

package package

class SearchController {

    def searchService

    def home = {SearchCommand filter ->

        SortedSet<Companies> companies = searchService.retrieveCompanies()
        render(view: '/index', model: [companies: companies, filter: filter])
    }
   ... // Code ommited
}

class SearchCommand implements Serializable, Comparable {
    String id
    String key
    String name


    static constraints = {
        ... // Code for key and name ommited
    }

    int compareTo(other) {
        if (other) {
            int value = compareTo(this.name, other?.name)
            if (value) return value
            value = compareTo(this.key, other?.key)
            if (value) return value
            value = compareTo(this.id, other?.id)
            if (value) return value
            return 0
        }
        return 1
    }
       
     private int compareTo(def main, def other) {
        return (main && other) ?
            main.compareTo(other) :
            (!main) ?
                ((!other) ?
                    0 :
                    -1) :
                1
    }

    String toUrlParams(Group group) {
        StringBuilder builder = new StringBuilder()

        if (group) {
            builder.append("group=").append(group).append("&")
        }

        if (key) {
            builder.append("key=").append(key).append("&")
        }

        if (nome) {
            builder.append("name=").append(name).append("&")
        }

        return builder.substring(0, builder.length() - 1).replaceAll(" ", "+")
    }
}

As you can see, SearchCommand is defined in the same file of
SearchController but it´s being interpreted as a controller also. I
have no problem compiling this code for grails 1.3.7.  Only in 2.0.1 I
got this message.

I don´t know if grails 2.0.0 has this behavior.

I got your point about public methods in controller but my method is
inside a Command not a Controller. What do you think about that?

Thanks for your help,

ACMattos.

On 2/15/12, Jeff Brown <[hidden email]> wrote:

> On Wed, Feb 15, 2012 at 7:27 AM, ACMattos <[hidden email]> wrote:
>
>>
>> Then a second error came:
>>
>> "Error Compilation error: startup failed:
>> D:\app\grails-app\controllers\package\SearchController.groovy: The
>> [toUrlParams] action accepts a parameter of type [package.enums.Group]
>> which
>> does not appear to be a command object class.  This can happen if the
>> source
>> code for this class is not in this project and the class is not marked
>> with
>> @Validateable."
>>
>> Group is a simple enum and "toUrlParams" is just a simple helper method of
>> SearchCommand object (written on the same file of
>> SearchController.groovy).
>> To get rid of this message, I had to put "SearchCommand" in its on file.
>>
>
> That does not sound right.  The error message suggests that the
> toUrlParams method is defined in the controller.  Your note says that
> it is defined in SearchCommand.  Are you sure that is correct?
>
> In Grails 2, all public methods defined in a controller are treated as
> controller actions.  If you have a helper method, it should not be
> public.
>
>
>
> jb
> --
> Jeff Brown
> SpringSource
> http://www.springsource.com/
>
> Autism Strikes 1 in 166
> Find The Cause ~ Find The Cure
> http://www.autismspeaks.org/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails 2.0.1 strange behaviour

Jeff Brown-3
On Wed, Feb 15, 2012 at 3:24 PM, ACMattos <[hidden email]> wrote:

> Hi Jeff,
>
> Thanks for your time. :-)
>
> The code is quite simple:
>
> package package
>
> class SearchController {
>
>    def searchService
>
>    def home = {SearchCommand filter ->
>
>        SortedSet<Companies> companies = searchService.retrieveCompanies()
>        render(view: '/index', model: [companies: companies, filter: filter])
>    }
>   ... // Code ommited
> }
>
> class SearchCommand implements Serializable, Comparable {
>    String id
>    String key
>    String name
>
>
>    static constraints = {
>        ... // Code for key and name ommited
>    }
>
>    int compareTo(other) {
>        if (other) {
>            int value = compareTo(this.name, other?.name)
>            if (value) return value
>            value = compareTo(this.key, other?.key)
>            if (value) return value
>            value = compareTo(this.id, other?.id)
>            if (value) return value
>            return 0
>        }
>        return 1
>    }
>
>     private int compareTo(def main, def other) {
>        return (main && other) ?
>            main.compareTo(other) :
>            (!main) ?
>                ((!other) ?
>                    0 :
>                    -1) :
>                1
>    }
>
>    String toUrlParams(Group group) {
>        StringBuilder builder = new StringBuilder()
>
>        if (group) {
>            builder.append("group=").append(group).append("&")
>        }
>
>        if (key) {
>            builder.append("key=").append(key).append("&")
>        }
>
>        if (nome) {
>            builder.append("name=").append(name).append("&")
>        }
>
>        return builder.substring(0, builder.length() - 1).replaceAll(" ", "+")
>    }
> }
>
> As you can see, SearchCommand is defined in the same file of
> SearchController but it´s being interpreted as a controller also. I
> have no problem compiling this code for grails 1.3.7.  Only in 2.0.1 I
> got this message.
>
> I don´t know if grails 2.0.0 has this behavior.
>
> I got your point about public methods in controller but my method is
> inside a Command not a Controller. What do you think about that?
>

That is a bug.  Please file a JIRA.  If you can attach a sample app,
that would be fantastic.

Thanks for the help.



jb



--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails 2.0.1 strange behaviour

ACMattos
Jeff,

Created: http://jira.grails.org/browse/GRAILS-8784

Thanks,

ACMattos.

On 2/15/12, Jeff Brown <[hidden email]> wrote:

> On Wed, Feb 15, 2012 at 3:24 PM, ACMattos <[hidden email]> wrote:
>> Hi Jeff,
>>
>> Thanks for your time. :-)
>>
>> The code is quite simple:
>>
>> package package
>>
>> class SearchController {
>>
>>    def searchService
>>
>>    def home = {SearchCommand filter ->
>>
>>        SortedSet<Companies> companies = searchService.retrieveCompanies()
>>        render(view: '/index', model: [companies: companies, filter:
>> filter])
>>    }
>>   ... // Code ommited
>> }
>>
>> class SearchCommand implements Serializable, Comparable {
>>    String id
>>    String key
>>    String name
>>
>>
>>    static constraints = {
>>        ... // Code for key and name ommited
>>    }
>>
>>    int compareTo(other) {
>>        if (other) {
>>            int value = compareTo(this.name, other?.name)
>>            if (value) return value
>>            value = compareTo(this.key, other?.key)
>>            if (value) return value
>>            value = compareTo(this.id, other?.id)
>>            if (value) return value
>>            return 0
>>        }
>>        return 1
>>    }
>>
>>     private int compareTo(def main, def other) {
>>        return (main && other) ?
>>            main.compareTo(other) :
>>            (!main) ?
>>                ((!other) ?
>>                    0 :
>>                    -1) :
>>                1
>>    }
>>
>>    String toUrlParams(Group group) {
>>        StringBuilder builder = new StringBuilder()
>>
>>        if (group) {
>>            builder.append("group=").append(group).append("&")
>>        }
>>
>>        if (key) {
>>            builder.append("key=").append(key).append("&")
>>        }
>>
>>        if (nome) {
>>            builder.append("name=").append(name).append("&")
>>        }
>>
>>        return builder.substring(0, builder.length() - 1).replaceAll(" ",
>> "+")
>>    }
>> }
>>
>> As you can see, SearchCommand is defined in the same file of
>> SearchController but it´s being interpreted as a controller also. I
>> have no problem compiling this code for grails 1.3.7.  Only in 2.0.1 I
>> got this message.
>>
>> I don´t know if grails 2.0.0 has this behavior.
>>
>> I got your point about public methods in controller but my method is
>> inside a Command not a Controller. What do you think about that?
>>
>
> That is a bug.  Please file a JIRA.  If you can attach a sample app,
> that would be fantastic.
>
> Thanks for the help.
>
>
>
> jb
>
>
>
> --
> Jeff Brown
> SpringSource
> http://www.springsource.com/
>
> Autism Strikes 1 in 166
> Find The Cause ~ Find The Cure
> http://www.autismspeaks.org/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails 2.0.1 strange behaviour

Jeff Brown-3
On Wed, Feb 15, 2012 at 4:16 PM, ACMattos <[hidden email]> wrote:
> Jeff,
>
> Created: http://jira.grails.org/browse/GRAILS-8784
>
> Thanks,
>
>

Fixed.

Thanks for the report.

(github is having problems right now so I can't get the fix pushed but
I will close the JIRA once the change can be pushed and we get a clean
build)



jb
--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...