Spring Mongo reactive Handle Database Error on Save - project-reactor

Can someone please help me as how do i handle database exception when i use Reactive Mongo with Spring webflux ...
I have a
Repository class
public interface UserRepository extends ReactiveMongoRepository<User,String>
{
public Mono<User> findByUserName(String userName);
}
Handler method in UserHandler
public Mono<ServerResponse> saveUser(ServerRequest request) {
Mono<User> user = request.bodyToMono(User.class).map(userObj -> {
userObj.setPassword(passwordEncoder.encode(userObj.getPassword()));
return userObj;
});
return
ServerResponse.ok().body(this.userRepository.insert(user),User.class);
}
I have defined a unique key on username so when the exception throw i want to return a meaningful message to use how can i use OnErrorMap to return a server reponse with message.
I get the below error in console but no error returned to the user
at sun.nio.ch.Invoker$2.run(Invoker.java:218) ~[na:1.8.0_60]
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) ~[na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_60]
Caused by: com.mongodb.MongoWriteException: E11000 duplicate key error collection: letsbuy.users index: username dup key: { : "asoni11" }
at com.mongodb.async.client.MongoCollectionImpl$8.onResult(MongoCollectionImpl.java:638) ~[mongodb-driver-async-3.4.3.jar:na]
... 163 common frames omitted

It's a bit counterintuitive, but in that case you need to do something like:
Mono<User> savedUser = request.bodyToMono(User.class).map(userObj -> {
userObj.setPassword(passwordEncoder.encode(userObj.getPassword()));
return userObj;
})
.flatMap(user -> this.userRepository.insert(user));
return savedUser
.flatMap(u -> ServerResponse.ok().syncBody(u))
.onErrorResume(DuplicateKeyException.class,
t -> ServerResponse.status(HttpStatus.BAD_REQUEST).syncBody(t.getMessage()));

Related

Spring elasticsearch java.net.UnknownHostException

Trying to update a small experimental Spring Elasticsearch project to reflect changes in the 3.2.6 release reference guide.
As noted: TransportClient is deprecated as of Elasticsearch 7 and will be removed in 8. Trying to reconfig to High Level Rest Client.
But getting the following errors
Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticDatasource' defined in file [/Users/erichuang/Desktop/JE/00-Development/dev/lab/lab-elastic-search/lab-elastic-search/target/classes/com/elastic/labelasticsearch/config/ElasticDatasource.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carElasticRepo': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]: Constructor threw exception; nested exception is org.springframework.data.elasticsearch.ElasticsearchException: Error while for indexExists request: org.elasticsearch.action.admin.indices.get.GetIndexRequest#b5d8ebb
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
com.elastic.labelasticsearch.LabElasticSearchApplication.main(LabElasticSearchApplication.java:15)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carElasticRepo': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]: Constructor threw exception; nested exception is org.springframework.data.elasticsearch.ElasticsearchException: Error while for indexExists request: org.elasticsearch.action.admin.indices.get.GetIndexRequest#b5d8ebb
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
... 24 common frames omitted
Caused by: java.net.UnknownHostException: localhost/<unresolved>: nodename nor servname provided, or not known
at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:932)
at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1505)
at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:851)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1495)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1354)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1288)
...
... 63 common frames omitted
Old setup (works)
ElasticSearchConfig
#Configuration
#EnableElasticsearchRepositories(basePackages = "com.elastic.labelasticsearch.repo")
public class ElasticSearchConfig {
private static final String esHost = "localhost";
private static final int esPort = 9300;
#Bean
public Client client() throws UnknownHostException {
var transportClient = new PreBuiltTransportClient(Settings.EMPTY);
transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName(esHost), esPort));
return transportClient;
}
#Bean(name ={"elasticsearchOperations", "elasticsearchTemplate"})
public ElasticsearchOperations esTemplate() throws UnknownHostException {
return new ElasticsearchTemplate(client());
}
#Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
}
New Setup
#Configuration
#EnableElasticsearchRepositories(basePackages = "com.elastic.labelasticsearch.repo")
public class RestClientConfig extends AbstractElasticsearchConfiguration {
#Override
#Bean
public RestHighLevelClient elasticsearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("localhost:9300")
.build();
return RestClients.create(clientConfiguration).rest();
}
}
What am I missing?
This is a bug resulting from as change in Java 14 in the java.net.InetSocketAddress.toString() method. This has been fixed in 4.0.RC2 (released yesterday).
Edit: I will backport this into the 3.2 branch as well
You will need to configure your bean using this way that allow to separate the host port and http protocol used:
#Configuration
#EnableElasticsearchRepositories(basePackages = "*")
public class ElasticsearchClientConfig {
#Value("${elasticsearch.host}")
private String host;
#Value("${elasticsearch.port}")
private int port;
#Value("${elasticsearch.protocol}")
private String protocol;
#Value("${elasticsearch.username}")
private String userName;
#Value("${elasticsearch.password}")
private String password;
#Bean(destroyMethod = "close")
public RestHighLevelClient restClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
RestClientBuilder builder = RestClient.builder(new HttpHost(host, port, protocol)).setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
RestHighLevelClient client = new RestHighLevelClient(builder);
return client;
}
}

unmarshalling domain class error in elastic search Grails

I'm trying to use ElasticSearch 1.0.0.2 in Grails 3.1.6.
The domain class is:
class Post {
String content
Date dateCreated
static belongsTo = [user: User]
static hasMany = [tags: Tag]
static searchable = {
tags component : true
user component: true
}
}
I've injected ElasticSearchService in my SearchController and trying to obtain search results as:
try {
def searchResult = elasticSearchService.search("${params.q}")
// def searchResult = Post.search("${params.q}")
println("search result: "+searchResult)
return [searchResult: searchResult]
}catch (e){
println e.message
return [searchError: true]
}
But getting error like this:
ERROR grails.plugins.elasticsearch.conversion.unmarshall.DomainClassUnmarshaller - Error unmarshalling property 'user' of Class Post with id 4
java.lang.IllegalStateException: Property Post.user is not mapped as [component], but broken search hit found.
at sun.reflect.GeneratedConstructorAccessor116.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1075)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at grails.plugins.elasticsearch.conversion.unmarshall.DomainClassUnmarshaller.unmarshallProperty(DomainClassUnmarshaller.groovy:206)
at sun.reflect.GeneratedMethodAccessor339.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1432)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:64)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:190)
Would someone please tell me what mistake i'm making. Thanks.
Had the same problem, used this piece from the elastisearch plugin documentation to change my component to references which fixed my problem:
3.8.1. Searchable Reference
The searchable-reference mapping mode is the default mode used for association, and requires the searchable class of the association to be root-mapped in order to have its own index. With this mode, the associated domains are not completely marshalled in the resulting JSON document: only the id and the type of the instances are kept. When the document is retrieved from the index, the plugin will automatically rebuild the association from the indices using the stored id.
Example
class MyDomain {
// odom is an association with the OtherDomain class, set as a reference
OtherDomain odom
static searchable = {
odom reference:true
}
}
// The OtherDomain definition, with default searchable
class OtherDomain {
static searchable = true
String field1 = "val1"
String field2 = "val2"
String field3 = "val3"
String field4 = "val4"
}
When indexing an instance of MyDomain, the resulting JSON documents will be sent to ElasticSearch:
{
"mydomain": {
"_id":1,
"odom": { "id":1 }
}
}
{
"otherdomain": {
"_id":1,
"field1":"val1",
"field2":"val2",
"field3":"val3",
"field4":"val4"
}
}
Here is the link to the documentation
http://noamt.github.io/elasticsearch-grails-plugin/docs/index.html#searchableComponentReference

Can't delegate methods within closure implicitly even with DELEGATE_FIRST/DELEGATE_ONLY resolve strategy

I have a method which extends all domain classes:
static def bindGormStaticApiExtensions() {
Holders.grailsApplication.domainClasses.each { domainClass ->
domainClass.metaClass.static.withDataSource = { DataSource ds, Closure callable ->
HibernateDatastore datastore = Holders.applicationContext.getBean(HibernateDatastore)
SessionFactory sessionFactory = datastore.sessionFactory
Session session = null
Connection connection = null
try {
SessionBuilder sb = sessionFactory.withOptions()
connection = ds.getConnection()
session = sb.connection(connection).openSession()
callable.delegate = delegate
callable.resolveStrategy = Closure.DELEGATE_FIRST
return callable?.call(session)
} catch (Exception e) {
LOG.error("An error occured", e)
} finally {
session?.close()
if(connection && !connection.closed) {
connection.close()
}
}
}
}
}
However when I call this method on a domain class, I have to use delegate.findByXXX() otherwise groovy uses owner even though I've explicitly set the closure resolve strategy to DELEGATE_FIRST.
What am I doing wrong here?
You were right, the problem is in Groovy. Here's a simple test which demonstrates the problem:
assert MyClass.thisMethodDoesNotExist() == 'You called static method thisMethodDoesNotExist'
assert new MyClass().thisMethodDoesNotExist() == 'You called instance method thisMethodDoesNotExist'
new MyClass().with {
assert thisMethodDoesNotExistEither() == 'You called instance method thisMethodDoesNotExistEither'
}
MyClass.with {
// The following method call will throw a groovy.lang.MissingMethodException
assert thisMethodDoesNotExistEither() == 'You called static method thisMethodDoesNotExistEither'
}
class MyClass {
static Object $static_methodMissing(String name, Object args) {
"You called static method $name"
}
Object methodMissing(String name, Object args) {
"You called instance method $name"
}
}
The stackstrace looks like this:
groovy.lang.MissingMethodException: No signature of method: ConsoleScript10.thisMethodDoesNotExistEither() is applicable for argument types: () values: []
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:81)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:158)
at ConsoleScript10$_run_closure2.doCall(ConsoleScript10:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at groovy.lang.Closure.call(Closure.java:426)
at groovy.lang.Closure.call(Closure.java:442)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(DefaultGroovyMethods.java:241)
at org.codehaus.groovy.runtime.dgm$757.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:91)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at ConsoleScript10.run(ConsoleScript10:8)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:524)
at groovy.lang.GroovyShell.run(GroovyShell.java:503)
at groovy.lang.GroovyShell.run(GroovyShell.java:170)
at groovy.lang.GroovyShell$run$1.call(Unknown Source)
at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy:980)
at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at groovy.lang.Closure.call(Closure.java:426)
at groovy.lang.Closure.call(Closure.java:420)
at groovy.lang.Closure.run(Closure.java:507)
at java.lang.Thread.run(Thread.java:724)
I have my suspicions, I don't have a full understanding of Groovy's MOP implementation, so I don't know how to fix this issue. There's an open bug that reflects this problem.
Work-around
Good news! There's a work-around for this problem. And it's super simple: instead of using a class as the delegate for the closure, use an
instance which wraps the class; a proxy.
static def bindGormStaticApiExtensions() {
Holders.grailsApplication.domainClasses.each { domainClass ->
domainClass.metaClass.static.withDataSource = { DataSource ds, Closure callable ->
HibernateDatastore datastore = Holders.applicationContext.getBean(HibernateDatastore)
SessionFactory sessionFactory = datastore.sessionFactory
Session session = null
Connection connection = null
try {
SessionBuilder sb = sessionFactory.withOptions()
connection = ds.getConnection()
session = sb.connection(connection).openSession()
// Use a proxy as the delegate instead of the domain class.
callable.delegate = new ClassProxy(delegate)
callable?.call(session)
} catch (Exception e) {
LOG.error("An error occured", e)
} finally {
session?.close()
if(connection && !connection.closed) {
connection.close()
}
}
}
}
}
Here's the proxy:
// src/main/groovy/some/package/ClassProxy.groovy
#groovy.transform.TupleConstructor
/*
* Create an instance of my like so: new ClassProxy(SomeClass)
* and I will delegate method calls to the Class,
* essentially converting instance method calls to Class static
* method calls.
*/
class ClassProxy {
Class clazz
Object methodMissing(String name, Object args) {
clazz.invokeMethod(name, args)
}
}
methodMissing(), which is what dynamic finders depend on, works fine for instances, so the proxy takes advantage of this and simply invokes whatever method you call on it, on the real Class. In this case a domain class. I'm not sure if you need to change the default resolve strategy, but I don't think so. In my testing it was unnecessary.
...otherwise groovy uses owner even though I've explicitly set the
closure resolve strategy to DELEGATE_FIRST.
I don't think that is correct.
You have the following:
callable.delegate = delegate
That is inside of the closure that you are assigning to withDataSource.
When you use ExpandoMetaClass in that way, the delegate of the closure will be the thing that you invoked the method on. In your case, it will be the thing that you invoked withDataSource on.

Grails 3 Interceptor and render custom JSON view

I am trying to write a Grails 3 interceptor that should check if certain variables are present in the HTTP Headers. If they are not present i would like to render a specific json view but it seems that the render method is not availble in the before() method.
boolean before() {
String header = request.getHeader("Authorization")
if(!header) {
BaseException exception = new BadRequestException("test")
render view: "/genericErrorReponse", model: [e: exception]
return false
}
Is there a better way to achieve the desired result?
I am getting the following error when trying to render the JSON view.
No qualifying bean of type [org.springframework.web.servlet.ViewResolver] is defined.
No qualifying bean of type [org.springframework.web.servlet.ViewResolver] is defined: expected single matching bean but found 4: groovyMarkupViewResolver,jsonViewResolver,beanNameViewResolver,mvcViewResolver. Stacktrace follows:
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.web.servlet.ViewResolver] is defined: expected single matching bean but found 4: groovyMarkupViewResolver,jsonViewResolver,beanNameViewResolver,mvcViewResolver
at grails.artefact.Interceptor$Trait$Helper.render(Interceptor.groovy:254) ~[grails-plugin-interceptors-3.1.1.jar:3.1.1]
at device.registration.RegistrationInterceptor.before(RegistrationInterceptor.groovy:13) ~[main/:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_66]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
Interceptor Code
class RegistrationInterceptor {
boolean before() {
String header = request.getHeader("Authorization")
if(!header) {
render view: "/genericErrorResponse", model: [e: new BadRequestException()]
}
false
}
boolean after() { true }
void afterView() {
// no-op
}
}
JSON View [/genericErrorResponse]
model {
BaseException e
}
response.status e.status
json {
message e.message
error e.error
status e.status
timestamp e.timestamp
}
Stacktrace shows that you are trying to get a bean of type org.springframework.web.servlet.ViewResolver at RegistrationInterceptor.groovy:13. Grails has by default 4 different implementations for ViewResolver and you have to be specific which one do you want to use.
It seemed that it actually was a bug inside Grails 3. Please see https://github.com/grails/grails-core/issues/9688

Grais listing based on embedded date field not working

I'm new to grails and trying to get a list of Domain based on Embedded class's date field.
Below are Working fine
def res = User.findAll { lt 'createdDateTime', new Date }
def res = User.findAll { eq 'account.name', 'JOHN' }
But,
def res = User.findAll { lt 'account.createdDateTime', new Date }
the above always return empty list.
'Account' class is embedded into User class
User.groovy
class User {
String name
Integer age
Date ctratedDateTime // test
Account account
static embedded = [
'account'
]
}
Account.groovy
class Account {
String userName
String password
Date createdDateTime
}
def res = User.findAll {
account{
lt 'createdDateTime', new Date
}
}
For above getting the following error
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [list] of controller [com.test.UserController] caused exception: Runtime error executing action
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
... 5 more
Caused by: java.lang.reflect.InvocationTargetException
... 5 more
Caused by: java.lang.NoSuchMethodError: com.test.UserController$_getFilteredForexRates_closure9.<init>(Ljava/lang/Object;Ljava/lang/Object;Lgroovy/lang/Reference;)V
at com.test.UserController$$EOqgV3Um.getFilteredForexRates(UserController.groovy:172)
at com.test.UserController$_closure5$$EOqgV3Um.doCall(UserController.groovy:109)
... 5 more
Am I doing in a correct way? Please suggest me the way to resolve.
Thanks.
you should use a nested closure:
def res = User.withCriteria{
account{
lt 'createdDateTime', new Date
}
}

Resources