Grails session cannot assign java.string - grails

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)

Related

How to fix groovy.lang.MissingMethodException: No signature of method when calculating the total

I am trying to connect to Cassandra and write a query in Grails to total the amount but I am getting a missing method exception:
groovy.lang.MissingMethodException: No signature of method: project
.sampleTest.column() is applicable for argument types: (java.lang.String) values: [amount]
Possible solutions: collect(), dump(), collect(groovy.lang.Closure)
Below is the query what I have written to sum the amount.
Select selectQuery = QueryBuilder.select().fcall("sum", column("amount")).from(tableName).allowFiltering()
Session session = cassandraTemplate.getSession();
Where selectWhere = selectQuery.where();
To use a column name inside of fcall() you need to use the static method QueryBuilder.column(). So when you use it in fcall() you need to call it like:
Select selectQuery = QueryBuilder.select().fcall("sum", QueryBuilder.column("amount")).from(tableName).allowFiltering()

No signature of method error while testing in grails

I have a very simple code in my test:
expect:
String test = "test123"
myHelper.myMethod(test) == "test"
The error I'm getting is:
| groovy.lang.MissingMethodException: No signature of method: com.some.helper.MyHelper.myMethod() is applicable for argument types: (java.lang.String) values: [test123] Possible solutions: myMethod(java.lang.String)
at com.some.helper.MyHelperSpec.test (MyHelperSpec.groovy:245)
My method expects a String and I'm passing a string. What am I missing here? FWIW, I'm using grails 2.5.3

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: getAll throwing no signature of method exception?

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)

Resources