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
Related
We have a project that we recently required the use of Camel in. This projects is a Groovy/Grails project and I have installed the Routing 1.4.1 plugin.
I then proceeded to create a new route as specified in the documentation which is shown below:
package some_package
import org.apache.camel.builder.RouteBuilder
class TestRoute extends RouteBuilder {
def grailsApplication
#Override
void configure() {
def config = grailsApplication?.config
// example:
from('seda:input.queue').to('stream:out')
}
}
Then I proceeded to setup a call to this Route in one of my Controllers using the following 'sendMessage' command:
//Camel Testing
def message = "This is some history"
sendMessage("seda:input.queue", message)
However when typing in the IDE the 'sendMessage' method it does say 'Type Not Found' which says to me maybe I am missing an import of something but according to the documentation this should be available to all Controllers and Services.
I added debug and the code hits the sendMessage line however does not get into the routing method.
Can someone please help with this?
Thanks
************UPDATE***********
So I installed everything again from scratch and used an older version of InteliJ and the simple example worked great.
Next I tried a more complex example of calling a service, however the app fails on startup, I have put the Service, Route and sendMessage data below:
Route
from("seda:input.queue").filter {
it.in.body.contains("test")
}.to("bean:TestService?method=printMsg")
Service
def printMsg(msg){
println(msg)
}
sendMessage
def myMessage = "this is a test message"
sendMessage("seda:input.queue", myMessage)
The error I get when running the app is below:
Error 2015-08-07 13:46:46,156 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: groovy.lang.MissingMethodException: No signature of method: org.grails.plugins.routing.processor.PredicateProcessor.to() is applicable for argument types: (java.lang.String) values: [bean:TestService?method=printMsg]
Possible solutions: is(java.lang.Object), any(), use([Ljava.lang.Object;), getAt(java.lang.String), with(groovy.lang.Closure), any(groovy.lang.Closure)
Message: groovy.lang.MissingMethodException: No signature of method: org.grails.plugins.routing.processor.PredicateProcessor.to() is applicable for argument types: (java.lang.String) values: [bean:TestService?method=printMsg]
Possible solutions: is(java.lang.Object), any(), use([Ljava.lang.Object;), getAt(java.lang.String), with(groovy.lang.Closure), any(groovy.lang.Closure)
I hope you can help.
Update
Ok so i removed the filter piece and the application loaded.
However when the sendMessage got run I got the following error:
Message: No bean could be found in the registry for: TestService
I then tried to add the bean manually using the following code but still get the same error:
void configure() {
def config = grailsApplication?.config
SimpleRegistry registry = new SimpleRegistry();
registry.put("TestService", new TestService());
CamelContext context = new DefaultCamelContext(registry);
from("seda:input.queue").to("bean:TestService?method=printMsg")
}
What you need to do is use ProducerTemplate class as follows:
CamelContext context //the Camel Context running your routes
ProducerTemplate template = context.createProducerTemplate()
Object resultBody = template.sendBody("seda:input.queue", "Your body")
println(resultBody) //anything that your route puts in the body
I have managed to fix this and it was down to a missname of the bean.
I found the error by listing all current beans in the context and then changing my call.
Thanks
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?
Trying to run the following command in grails console:
Family.where() {password =~ "%qw%"}
A very simple query on a stored object. I'm getting back:
ERROR groovy.lang.MissingMethodException:
No signature of method: com.babyboom.Family.where() is applicable for argument types: (groovysh_evaluate$_run_closure1) values: [groovysh_evaluate$_run_closure1#34356294]
Possible solutions: where(groovy.lang.Closure), merge(), every(), grep(), merge(com.babyboom.Family), merge(java.util.Map)
I understand that the closure I created is a different than the expected one.
Couple of questions:
Why there are 2 types of closures ?
Found Why am I getting a "No signature of method"" error when running the closure recursion example in the Groovy shell? tried it and it didn't help, still getting the same error
It works well when using grails console
This is likely a classloader bug with the grails shell. To reproduce, add dependency to BuildConfig.gradle:
runtime "org.grails:grails-datastore-simple:3.1.2.RELEASE"
then run
import org.grails.datastore.mapping.simple.SimpleMapDatastore
import org.grails.datastore.gorm.GormStaticApi
class Bar {}
class Foo extends GormStaticApi<Bar> {
Foo() {
super(Bar, new SimpleMapDatastore(), [], null)
}
}
def f = new Foo()
In grails console yields:
Result: Foo#699c0395
In grails shell yields:
groovy:000> def f = new Foo()
ERROR java.lang.LinkageError:
loader constraint violation: when resolving overridden method "Foo.$getStaticMetaClass()Lgroovy/lang/MetaClass;" the class loader (instance of groovy/lang/GroovyClassLoader$InnerLoader) of the current class, Foo, and its superclass loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader), have different Class objects for the type ()Lgroovy/lang/MetaClass; used in the signature
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)
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)