Grails: getAll throwing no signature of method exception? - grails

According to the Grails literature
http://grails.org/doc/2.0.x/ref/Domain%20Classes/getAll.html
I should be able to do this
def biweeklyBatchRanges = BiweeklyBatchRange.getAll()
without getting this
groovy.lang.MissingMethodException: No signature of method: com.myplang.donation.BiweeklyBatchRange.getAll() is applicable for argument types: () values: []
Possible solutions: getAll(), getAt(java.lang.String), getId(), get(java.io.Serializable), getClass(), findAll()
Any ideas? TIA!

Never got an "answer" to this, except to use findAll. (Grails 2.0.3)

Related

Grails where clause, why cant i search where id == id?

This has been bothering me for a bit. The following query works:
Receipt.where{project.customer == customer}.list()
but this query throws an exception
Receipt.where{project.customer.id==customer.id}.list()
exception:
Class
groovy.lang.MissingMethodException Message
No signature of method: receiptbucketserver.Customer.call() is applicable for argument types:
(receiptbucketserver.ReceiptHelperService$_tt__getReceiptsByCustomer_closure11_closure12_closure13)
values:
[receiptbucketserver.ReceiptHelperService$_tt__getReceiptsByCustomer_closure11_closure12_closure13#170130c3]
Possible solutions: wait(), last(), save(), any(), getAll(),
wait(long)

Loop through each entity of a domain class in a service

I have a domain class called StatusReport. I also have a service called StatusReportsService.
Grails documentation gives examples like:
Book.list().each{}
However I get an error when I use:
StatusReport.list().each{}
Which gives me the error
Message: No signature of method: static com.tr.StatusReport.list() is applicable for argument types: () values: []
Possible solutions: is(java.lang.Object), wait(), find(), wait(long), print(java.io.PrintWriter), find(groovy.lang.Closure)
How can I loop through each domain entity in a service?

grails test-app integration coverage giving error

My code
def baseRecordList = DealerBaseInfo.findAll("from DealerBaseInfo as dealers",[cache: false])
is giving the below error inside PriorApprovalController.groovy
groovy.lang.MissingMethodException: No signature of method: DealerBaseInfo.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at DealerBaseInfo.findAll(DealerBaseInfo.groovy)
at DealerBaseInfo$findAll.call(Unknown Source)
PriorApprovalController.<init>(PriorApprovalController.groovy:37)
... 42 more
| Error Exception occurred trigger event [TestPhasesEnd]: Could not create a new instance of class [PriorApprovalController]!`
grails version is 2.1.1 and code-coverage plugin 1.2.5
Why is that and how do I fix it?
Have a look at the findAll() supported signatures: http://grails.org/doc/2.1.0/ref/Domain%20Classes/findAll.html
To use the queryParams, I think you should do something like this:
def baseRecordList = DealerBaseInfo.findAll("from DealerBaseInfo as dealers", [], [cache: false])
actually the error was coming because of class level access of findAll method i have written a static method in domain for findAll and access that method in controller then it worked

Grails session cannot assign java.string

I'm getting this error
Error 500: Executing action [pay] of controller [org.gamestrike.PaymentController] caused exception: groovy.lang.MissingMethodException: No signature of method: org.gamestrike.PaymentController.session() is applicable for argument types: (java.lang.String) values: [2011-09-15] Possible solutions: getSession()
Servlet: grails
URI: /GameStrike/grails/payment/pay.dispatch
Exception Message: No signature of method: org.gamestrike.PaymentController.session() is applicable for argument types: (java.lang.String) values: [2011-09-15] Possible solutions: getSession()
Caused by: No signature of method: org.gamestrike.PaymentController.session() is applicable for argument types: (java.lang.String) values: [2011-09-15] Possible solutions: getSession()
Class: PaymentController
At Line: [35]
Code Snippet:
Without your code it's hard to tell, but it looks like you're treating session like a method, but it's not. It's an object - the HttpSession instance.
You can call the standard methods on it, e.g. getAttribute and setAttribute but Grails adds convenience behavior. It acts like a Map so to set or get attributes you can do this:
def foo = session.foo // session.getAttribute('foo')
session.bar = 123 // session..setAttribute('bar', 123)

Grails Webflow errors on first access

I've developed a simple webflow in Grails (mostly to experiment with using webflows- its a bit overkill for this case). After some trials and tribulations with Serializable objects, I have it working - sometimes.
Here's the rub- the first time I access the webflow after starting the app (run-app), I get this exception:
2010-06-16 09:11:25,580 [http-8080-3] [ERROR] [org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver] No signature of method: groovy.lang.MissingMethodException.to() is applicable for argument types: (java.lang.String) values: [validate]
Possible solutions: is(java.lang.Object), any(), use([Ljava.lang.Object;), getAt(java.lang.String), with(groovy.lang.Closure), any(groovy.lang.Closure)
groovy.lang.MissingMethodException: No signature of method: groovy.lang.MissingMethodException.to() is applicable for argument types: (java.lang.String) values: [validate]
Possible solutions: is(java.lang.Object), any(), use([Ljava.lang.Object;), getAt(java.lang.String), with(groovy.lang.Closure), any(groovy.lang.Closure)
at com.sbs.component.survey.SurveyDefinitionController.invokeMethod(SurveyDefinitionController.groovy)
at com.sbs.component.survey.SurveyDefinitionController$_closure3.doCall(SurveyDefinitionController.groovy:23)
If I "touch" the controller (make any edit, even if just adding a white-space) and then save the file, the webflow starts to work... it seems something is not getting wired up until the controller reloads at least once. Obviously this is a non-starter... any ideas what's causing this?
I'm using Grails 1.3.1 on Mac OSX Java 1.6.
Here's the skeleton of the webflow:
def createSurveyFlow = {
select {
}.to("validate")
on("cancel").to("finish")
}
validate {
on("approve") {
}.to("finish")
on("disapprove").to("select")
on("cancel").to("finish")
}
finish {
action {
flash.message = "SurveyDefinition created"
}
redirect(controller:"surveyDefinition", action:"index")
}
}
I may have figured it out- it seems out that webflow definitions and controller actions don't much like being on the same controller. When I moved the webflow to it's own controller, this (and other) issues seemed to go away. For now, at least. I'll report back if/when I learn more.

Resources