grails 3.1.1 & json views - json

I've been playing around with Grails-3.1.1 and creating restful services but when I use them to generate from a collection and responding using templates I get the following error:
URI /api/buildings
Class java.lang.IllegalStateException
Message
Error rendering view: Error rendering view: Cannot write a name when a name has just been written. Write a value first!
Caused by
Cannot write a name when a name has just been written. Write a value first!
I followed the example on the json-views github page
https://github.com/grails/grails-views
My index.gson file looks like this
model {
List<Building> buildingList
}
json tmpl.building(buildingList)
And my _building.gson template file like this
model {
Building building
}
json g.render(building)
If I don't use the templates all works well but then I get too little info - I want to expand on some of the object relationships instead of just returning the id. Using a show.gson template accessing the same _building.gson file does seem to work OK. The controller in question extends from RestfulController and only implements the contructor as shown below
#Transactional(readOnly = true)
class BuildingRestController extends RestfulController {
static responseFormats = ['json', 'xml']
BuildingRestController() {
super(Building)
}
}
Any ideas what is going wrong and do others have it working?
Stack trace:
Line | Method
->> 8 | writeTo in C:\Users\Colin\code\biztool\grails-app\views\buildingRest\index.gson
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by ViewRenderException: Error rendering view: Cannot write a name when a name has just been written. Write a value first!
->> 8 | writeTo in C:\Users\Colin\code\biztool\grails-app\views\buildingRest\_building.gson
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by IllegalStateException: Cannot write a name when a name has just been written. Write a value first!
->> 624 | writeName in grails.plugin.json.builder.StreamingJsonBuilder$StreamingJsonDelegate
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 563 | call in ''
| 149 | process . . . . . . . . in grails.plugin.json.view.api.internal.JsonGrailsViewHelper
| 74 | doCall in grails.plugin.json.view.api.internal.JsonGrailsViewHelper$_render_closure1
| 689 | cloneDelegateAndGetContent in grails.plugin.json.builder.StreamingJsonBuilder$StreamingJsonDelegate
| 681 | cloneDelegateAndGetContent in ''
| 199 | call . . . . . . . . . in grails.plugin.json.builder.StreamingJsonBuilder
| 72 | render in grails.plugin.json.view.api.internal.JsonGrailsViewHelper
| 58 | render . . . . . . . . in ''
| 8 | run in _info_app_name__buildingRest__building_gson
| 32 | doWrite . . . . . . . . in grails.plugin.json.view.JsonViewTemplate
| 30 | writeTo in grails.views.AbstractWritableScript
| 280 | render . . . . . . . . in grails.plugin.json.view.api.internal.JsonGrailsViewHelper
| 30 | invokeMethod in grails.plugin.json.view.api.internal.TemplateRenderer
| 8 | run . . . . . . . . . . in _info_app_name__buildingRest_index_gson
| 32 | doWrite in grails.plugin.json.view.JsonViewTemplate
| 30 | writeTo . . . . . . . . in grails.views.AbstractWritableScript
| 64 | renderMergedOutputModel in grails.views.mvc.GenericGroovyTemplateView
| 94 | render . . . . . . . . in grails.views.mvc.renderer.DefaultViewRenderer
| 188 | internalRespond in grails.artefact.controller.RestResponder$Trait$Helper
| 62 | respond . . . . . . . . in ''
| 64 | index in grails.rest.RestfulController
| 96 | doInTransaction . . . . in grails.transaction.GrailsTransactionTemplate$2
| 93 | execute in grails.transaction.GrailsTransactionTemplate
| 80 | doFilter . . . . . . . in grails.plugin.springsecurity.rest.RestLogoutFilter
| 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
| 143 | doFilter . . . . . . . in grails.plugin.springsecurity.rest.RestAuthenticationFilter
| 62 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 58 | doFilter . . . . . . . in grails.plugin.springsecurity.web.SecurityRequestHolderFilter
| 35 | doFilterInternal in CorsFilter.java
| 1142 | runWorker . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 617 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . in java.lang.Thread

Related

Jersey Sub-Resource Locators Error

I'm trying to get the JSR-311 plugin working with Grails 2.3.7. I'm using version 0.10, because I think 0.11 requires Grails 2.4.
I've used the generate-resource command to create an end point for my domain class Product. Two resource classes are created, ProductCollectionResource and ProductResource. I've tweaked them a bit, but essentially they look like this:
ProductCollectionResource
#Path('/api/products')
#Consumes(['application/json'])
#Produces(['application/json'])
class ProductCollectionResource {
def productResourceService
#Path('{id}')
#GET
ProductResource getResource(#PathParam('id') Long id) {
new ProductResource(productResourceService: productResourceService, id:id)
}
#GET
Response readAll(#QueryParam("max") Integer max, #QueryParam("offset") Integer offset) {
ok productResourceService.readAll(max, offset)
}
}
ProductResource
#Consumes(['application/json'])
#Produces(['application/json'])
class ProductResource {
def productResourceService
def id
#GET
Response read() {
ok productResourceService.read(id)
}
}
The readAll method in ProductCollectionResource works fine - when I hit it, I get back a list of products, however when I try to access a specific product by id (on /api/products/123), I get the following error:
Caused by MessageException: A message body writer for Java class com.myapp.ProductResource, and Java type class com.myapp.ProductResource, and MIME media type application/json was not found
->> 285 | write in com.sun.jersey.spi.container.ContainerResponse
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1479 | _handleRequest in com.sun.jersey.server.impl.application.WebApplicationImpl
| 1391 | handleRequest . . in ''
| 1381 | handleRequest in ''
| 416 | service . . . . . in com.sun.jersey.spi.container.servlet.WebComponent
| 538 | service in com.sun.jersey.spi.container.servlet.ServletContainer
| 716 | service . . . . . in ''
| 193 | process in org.grails.jaxrs.web.JaxrsContext$JaxrsServiceImpl
| 45 | handle . . . . . . in org.grails.jaxrs.JaxrsController
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 150 | invoke in net.bull.javamelody.JspWrapper
| 285 | invoke . . . . . . in net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler
| 198 | doFilter in net.bull.javamelody.MonitoringFilter
| 176 | doFilter . . . . . in ''
| 67 | doFilter . . . . . in ''
| 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
| 82 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 63 | doFilter . . . . . in com.odobo.grails.plugin.springsecurity.rest.RestLogoutFilter
| 46 | doFilterInternal in org.grails.jaxrs.web.JaxrsFilter
| 82 | doFilter . . . . . in com.brandseye.cors.CorsFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
So it looks like it's trying to marshall my ProductResource class to JSON, which I think isn't really what I want. I think it should be invoking the ProductResource.read() method, and marshalling the returned value from that method to JSON.
I have no experience in Grails whatsoever, but from a pure Jersey standpoint, look at what you got here
#Path('{id}')
#GET
ProductResource getResource(#PathParam('id') Long id) {
This is resource method (endpoint). So the ProductsResource will be treated as the response body, just like any other resource method.
You seem to be trying to use the sub-resource locator functionality, forwarding to the ProductsResource class. For that to work, the sub-resource locator (getResource) should not have an #HttpMethod annotation. That's one of the factors that differentiates a resource method from a sub-resource locator.
So just remove the #GET from the getResource method. The #GET is already established by the read() method in the ProductsResource, which is what will be called.
For more information, see the documentation for Sub-Resource Locators

Grails Unable to create initial connections of pool

When I run my Grails app and I get the following error
| Loading Grails 2.3.5
| Configuring classpath
| Configuring classpath.
| Environment set to development
| Environment set to development.
| Environment set to development..
| Environment set to development...
| Environment set to development....
| Environment set to development.....
| Packaging Grails application
| Packaging Grails application.
| Packaging Grails application..
| Packaging Grails application...
| Packaging Grails application....
| Packaging Grails application.....
| Compiling 1 source files
| Compiling 1 source files.
| Compiling 1 source files..
| Compiling 1 source files...
| Compiling 1 source files....
| Compiling 1 source files.....
| Running Grails application
| Error 2015-04-21 11:54:24,947 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool .
Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Line | Method
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket . . . . . . . . . in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO . . . . . . . . . in ''
| 834 | <init> in ''
| 47 | <init> . . . . . . . . . . . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >| 600 | readPacket in ''
| 1088 | doHandshake . . . . . . . . . in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly . . . . . . in ''
| 2311 | createNewIO in ''
| 834 | <init> . . . . . . . . . . . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance . . . . . . in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . . . . . . . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . . . . in java.lang.Thread
| Error 2015-04-21 11:54:25,051 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool .
Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Line | Method
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket . . . . . . . . . in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO . . . . . . . . . in ''
| 834 | <init> in ''
| 47 | <init> . . . . . . . . . . . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >| 600 | readPacket in ''
| 1088 | doHandshake . . . . . . . . . in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly . . . . . . in ''
| 2311 | createNewIO in ''
| 834 | <init> . . . . . . . . . . . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance . . . . . . in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . . . . . . . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . . . . in java.lang.Thread
| Error 2015-04-21 11:54:25,139 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool .
Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Line | Method
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket . . . . . . . . . in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO . . . . . . . . . in ''
| 834 | <init> in ''
| 47 | <init> . . . . . . . . . . . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >| 600 | readPacket in ''
| 1088 | doHandshake . . . . . . . . . in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly . . . . . . in ''
| 2311 | createNewIO in ''
| 834 | <init> . . . . . . . . . . . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance . . . . . . in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . . . . . . . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . . . . in java.lang.Thread
| Error 2015-04-21 11:54:25,169 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Err>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org .spr
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. > Line | Method>->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFac tor>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDete cto>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exc ept>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is com.mysql.jdbc.exceptions.jdbc4.C omm>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO in ''
| 834 | <init> in ''
| 47 | <init> . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 600 | readPacket in ''
| 1088 | doHandshake in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO in ''
| 834 | <init> . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . in java.lang.Thread
| Error Forked Grails VM exited with error
| Server running. Browse to http://localhost:8080/TestDebug
and my code is the following:
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
// cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost/nuage_v3"
driverClassName = "com.mysql.jdbc.Driver"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
username = "root"
password = "root"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=false
validationQuery="SELECT 1"
jdbcInterceptors="ConnectionState"
}
}
}
}
The user and password are both correct, I tried reinstalling MySQL.
I've given up on trying to solve the problem.
I reinstalled grails and mysql on a diffenrent machine and it seems to work.
sorry to have bothered you all.
Thank you.
Problem is Mysql is not running.First run apache and Mysql then run grails app.Hope it will works .Also check 80 port is free or not if not then free your 80 port.
The same problem.. All of a sudden..
MySQLWorkbench works well, but grails "Unable to create initial connections of pool"
I've been spend half a day trying to fix this, searching answers. But nothing work for me..

IllegalArgumentException when parsing JSON array with one item

I really need some help with something in Grails.
I'm new to Grails, and making a backend for a gymnasium that handles routines, measurements, etc.
The problem I have is when parsing a JSON to create a routine for a new or existing client.
The routine is composed by a list of days, of a maximum of 4 days total.
To make long story short, when the JSON request is with only 1 day, I get the IllegalArgumentException and I'm running out of ideas regarding of why.
Please help me!
Here's a sample json:
{"objetivo":"test martes","fechaRealizacion":"2015-01-20T00:00:00Z","carne":115500153,"dias":[{"numDia":"1","ejercicios":[{"descripcionTrans":"1.1","idHoja":1},{"descripcionTrans":"1.2","idHoja":2},{"descripcionTrans":"1.3","idHoja":3}]}]}
And here's is the code where I parse the JSON request:
def guardar = {
println request.JSON
jsonObj = request.JSON
Rutinas r = new Rutinas(jsonObj)
def ide = request.JSON.carne?.toLong() ?:0
r.perfilAsociado = requestService.getPerfil(ide)
r.observaciones = r.perfilAsociado.observaciones
println jsonObj
ArrayList test = jsonObj.dias
ArrayList<Dia> dias = new ArrayList<Dia>()
def testO
for(int i = 0; i < test.size(); i++) {
Dia d = test.get(i)
ArrayList<Ejercicios> ejerAdd = new ArrayList<Ejercicios>()
for(int j = 0; j < d.ejercicios.size(); j++) {
testO = [idHoja: d.ejercicios.get(j).idHoja]
Ejercicios e = Ejercicios.findByIdHoja(testO.idHoja)
ejerAdd.add(e)
}
d.ejercicios = ejerAdd
dias.add(d)
}
r.dias = dias
/**/
try {
insertRutinas(r)
insertDia(r, jsonObj)
}catch(Exception ex) {
response.status = 500
println ex
render "Internal server error"
}
response.status = 201
render r as JSON//requestService.encodeRutinas(r)
}
Edit:
The error is thrown when calling ArrayList test = jsonObj.dias
Here's the stacktrace:
| Error 2015-01-21 09:18:04,884 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [POST] /backend-gimnasio/rutinas/guardar/
argument type mismatch. Stacktrace follows:
Message: argument type mismatch
Line | Method
->> -2 | invoke0 in sun.reflect.NativeMethodAccessorImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 57 | invoke in ''
| 43 | invoke . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
| 606 | invoke in java.lang.reflect.Method
| 1270 | jlrMethodInvoke . . . . . . . . in org.springsource.loaded.ri.ReflectiveInterceptor
| 90 | invoke in org.codehaus.groovy.reflection.CachedMethod
| 324 | doMethodInvoke . . . . . . . . in groovy.lang.MetaMethod
| 2662 | setProperty in groovy.lang.MetaClassImpl
| 1170 | setProperty . . . . . . . . . . in groovy.lang.ExpandoMetaClass
| 3702 | setProperty in groovy.lang.MetaClassImpl
| 1741 | setProperties . . . . . . . . . in ''
| 1718 | invokeConstructor in ''
| 1526 | invokeConstructor . . . . . . . in ''
| 675 | invokeConstructor in groovy.lang.ExpandoMetaClass
| 932 | invokeConstructorOf . . . . . . in org.codehaus.groovy.runtime.InvokerHelper
| 362 | continueCastOnSAM in org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation
| 306 | continueCastOnNumber . . . . . in ''
| 262 | continueCastOnCollection in ''
| 214 | castToType . . . . . . . . . . in ''
| 599 | castToType in org.codehaus.groovy.runtime.ScriptBytecodeAdapter
| 386 | doCall . . . . . . . . . . . . in gimnasio.backend.RutinasController$_closure2
| -1 | doCall in ''
| -2 | invoke0 . . . . . . . . . . . . in sun.reflect.NativeMethodAccessorImpl
| 57 | invoke in ''
| 43 | invoke . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
| 606 | invoke in java.lang.reflect.Method
| 1270 | jlrMethodInvoke . . . . . . . . in org.springsource.loaded.ri.ReflectiveInterceptor
| 90 | invoke in org.codehaus.groovy.reflection.CachedMethod
| 324 | doMethodInvoke . . . . . . . . in groovy.lang.MetaMethod
| 1207 | invokeMethod in groovy.lang.MetaClassImpl
| 1110 | invokeMethod . . . . . . . . . in groovy.lang.ExpandoMetaClass
| 1016 | invokeMethod in groovy.lang.MetaClassImpl
| 423 | call . . . . . . . . . . . . . in groovy.lang.Closure
| -1 | call in gimnasio.backend.RutinasController$_closure2
| 417 | call . . . . . . . . . . . . . in groovy.lang.Closure
| -1 | call in gimnasio.backend.RutinasController$_closure2
| -2 | invoke0 . . . . . . . . . . . . in sun.reflect.NativeMethodAccessorImpl
| 57 | invoke in ''
| 43 | invoke . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
| 606 | invoke in java.lang.reflect.Method
| 1270 | jlrMethodInvoke . . . . . . . . in org.springsource.loaded.ri.ReflectiveInterceptor
| 154 | invoke in org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper
| 375 | handleAction . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper
| 252 | executeAction in ''
| 205 | handleURI . . . . . . . . . . . in ''
| 126 | handleURI in ''
| 72 | handleRequest . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController
| 50 | handle in org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter
| 347 | doDispatch . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet
| 870 | doService in org.springframework.web.servlet.DispatcherServlet
| 961 | processRequest . . . . . . . . in org.springframework.web.servlet.FrameworkServlet
| 863 | doPost in ''
| 646 | service . . . . . . . . . . . . in javax.servlet.http.HttpServlet
| 837 | service in org.springframework.web.servlet.FrameworkServlet
| 727 | service . . . . . . . . . . . . in javax.servlet.http.HttpServlet
| 303 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter . . . . . . . . . . . in ''
| 52 | doFilter in org.apache.tomcat.websocket.server.WsFilter
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 198 | doFilter . . . . . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 344 | invokeDelegate . . . . . . . . in org.springframework.web.filter.DelegatingFilterProxy
| 261 | doFilter in ''
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 101 | doFilter . . . . . . . . . . . in org.springframework.web.filter.OncePerRequestFilter
| 241 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter . . . . . . . . . . . in ''
| 101 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 101 | doFilter . . . . . . . . . . . in org.springframework.web.filter.OncePerRequestFilter
| 241 | internalDoFilter in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter . . . . . . . . . . . in ''
| 748 | invoke in org.apache.catalina.core.ApplicationDispatcher
| 486 | processRequest . . . . . . . . in ''
| 411 | doForward in ''
| 338 | forward . . . . . . . . . . . . in ''
| 178 | forwardRequestForUrlMappingInfo in org.codehaus.groovy.grails.web.mapping.UrlMappingUtils
| 144 | forwardRequestForUrlMappingInfo in ''
| 135 | forwardRequestForUrlMappingInfo in ''
| 216 | doFilterInternal . . . . . . . in org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter
| 107 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 330 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 118 | invoke in org.springframework.security.web.access.intercept.FilterSecurityInterceptor
| 84 | doFilter . . . . . . . . . . . in ''
| 342 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 113 | doFilter . . . . . . . . . . . in org.springframework.security.web.access.ExceptionTranslationFilter
| 342 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 113 | doFilter . . . . . . . . . . . in org.springframework.security.web.access.ExceptionTranslationFilter
| 342 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| -1 | call . . . . . . . . . . . . . in javax.servlet.FilterChain$doFilter
| 108 | processFilterChain in com.odobo.grails.plugin.springsecurity.rest.RestTokenValidationFilter
| -1 | this$3$processFilterChain . . . in ''
| 77 | doFilter in ''
| 342 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
| 342 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 146 | doFilter in org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter
| 342 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 154 | doFilter in org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter
| 342 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| -1 | call in javax.servlet.FilterChain$doFilter
| 122 | doFilter . . . . . . . . . . . in com.odobo.grails.plugin.springsecurity.rest.RestAuthenticationFilter
| 342 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 199 | doFilter . . . . . . . . . . . in org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
| 49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
| 342 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 82 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 342 | doFilter . . . . . . . . . . . in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| -1 | call in javax.servlet.FilterChain$doFilter
| 63 | doFilter . . . . . . . . . . . in com.odobo.grails.plugin.springsecurity.rest.RestLogoutFilter
| 342 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 87 | doFilter . . . . . . . . . . . in org.springframework.security.web.context.SecurityContextPersistenceFilter
| 342 | doFilter in org.springframework.security.web.FilterChainProxy$VirtualFilterChain
| 192 | doFilterInternal . . . . . . . in org.springframework.security.web.FilterChainProxy
| 160 | doFilter in ''
| 344 | invokeDelegate . . . . . . . . in org.springframework.web.filter.DelegatingFilterProxy
| 261 | doFilter in ''
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 69 | doFilterInternal . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter
| 107 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 67 | doFilterInternal . . . . . . . in org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter
| 107 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 88 | doFilterInternal . . . . . . . in org.springframework.web.filter.CharacterEncodingFilter
| 107 | doFilter in org.springframework.web.filter.OncePerRequestFilter
| 344 | invokeDelegate . . . . . . . . in org.springframework.web.filter.DelegatingFilterProxy
| 261 | doFilter in ''
| 241 | internalDoFilter . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
| 208 | doFilter in ''
| 220 | invoke . . . . . . . . . . . . in org.apache.catalina.core.StandardWrapperValve
| 122 | invoke in org.apache.catalina.core.StandardContextValve
| 171 | invoke . . . . . . . . . . . . in org.apache.catalina.core.StandardHostValve
| 103 | invoke in org.apache.catalina.valves.ErrorReportValve
| 116 | invoke . . . . . . . . . . . . in org.apache.catalina.core.StandardEngineValve
| 408 | service in org.apache.catalina.connector.CoyoteAdapter
| 1070 | process . . . . . . . . . . . . in org.apache.coyote.http11.AbstractHttp11Processor
| 611 | process in org.apache.coyote.AbstractProtocol$AbstractConnectionHandler
| 316 | run . . . . . . . . . . . . . . in org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
| 61 | run in org.apache.tomcat.util.threads.TaskThread$WrappingRunnable
^ 745 | run . . . . . . . . . . . . . . in java.lang.Thread

"Duplicate entry '' for key" in Grails Database Migration using hasOne

Using Grails Database Migration Plugin 1.4 I want have the following structure of my existing database:
class StickerGroup {
}
Now I added the class Company and updated the class StickerGroup:
class StickerGroup {
static constraints = { company nullable: true, unique: true }
static belongsTo = [company: Company]
}
class Company {
static hasOne = [stickerGroup: StickerGroup]
}
I created the migration file and then I perform grails dbm-update. After that I get the following error log:
2015-01-20 15:03:49,549 [main] ERROR liquibase - Change Set 2015-01-20-update-Company.groovy::1421762562430-2::mg (generated) failed. Error: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id'
Message: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id'
Line | Method
->> 62 | execute in liquibase.executor.jvm.JdbcExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 104 | execute in ''
| 1091 | execute . . . . . in liquibase.database.AbstractDatabase
| 1075 | executeStatements in ''
| 317 | execute . . . . . in liquibase.changelog.ChangeSet
| 27 | visit in liquibase.changelog.visitor.UpdateVisitor
| 58 | run . . . . . . . in liquibase.changelog.ChangeLogIterator
| 114 | update in liquibase.Liquibase
| 26 | doCall . . . . . in DbmUpdate$_run_closure1_closure2
| 59 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2_closure11
| 133 | executeInSession in grails.plugin.databasemigration.MigrationUtils
| 51 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2
^ 25 | doCall . . . . . in DbmUpdate$_run_closure1
Caused by MySQLIntegrityConstraintViolationException: Duplicate entry '' for key 'company_id'
->> 377 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 360 | getInstance in ''
| 971 | createSQLException in com.mysql.jdbc.SQLError
| 3887 | checkErrorPacket in com.mysql.jdbc.MysqlIO
| 3823 | checkErrorPacket in ''
| 2435 | sendCommand in ''
| 2582 | sqlQueryDirect . in ''
| 2526 | execSQL in com.mysql.jdbc.ConnectionImpl
| 2484 | execSQL . . . . . in ''
| 848 | execute in com.mysql.jdbc.StatementImpl
| 742 | execute . . . . . in ''
| 92 | doInStatement in liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback
| 55 | execute . . . . . in liquibase.executor.jvm.JdbcExecutor
| 104 | execute in ''
| 1091 | execute . . . . . in liquibase.database.AbstractDatabase
| 1075 | executeStatements in ''
| 317 | execute . . . . . in liquibase.changelog.ChangeSet
| 27 | visit in liquibase.changelog.visitor.UpdateVisitor
| 58 | run . . . . . . . in liquibase.changelog.ChangeLogIterator
| 114 | update in liquibase.Liquibase
| 26 | doCall . . . . . in DbmUpdate$_run_closure1_closure2
| 59 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2_closure11
| 133 | executeInSession in grails.plugin.databasemigration.MigrationUtils
| 51 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2
^ 25 | doCall . . . . . in DbmUpdate$_run_closure1
liquibase.exception.MigrationFailedException: Migration failed for change set 2015-01-20-update-Company.groovy::1421762562430-2::mg (generated):
Reason: liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id':
Caused By: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id':
Caused By: Duplicate entry '' for key 'company_id'
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:347)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at liquibase.Liquibase.update(Liquibase.java:114)
at DbmUpdate$_run_closure1_closure2.doCall(DbmUpdate:26)
at _DatabaseMigrationCommon_groovy$_run_closure2_closure11.doCall(_DatabaseMigrationCommon_groovy:59)
at grails.plugin.databasemigration.MigrationUtils.executeInSession(MigrationUtils.groovy:133)
at _DatabaseMigrationCommon_groovy$_run_closure2.doCall(_DatabaseMigrationCommon_groovy:51)
at DbmUpdate$_run_closure1.doCall(DbmUpdate:25)
Caused by: liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id'
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104)
at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1091)
at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:1075)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
... 8 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '' for key 'company_id'
at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
at com.mysql.jdbc.Util.getInstance(Util.java:360)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:971)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2526)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2484)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:848)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:742)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
... 12 more
How can I fix this error?

Grails DetachedCriteria using 'where' throw SyntaxErrorException

I am trying to do the next select:
ArrayList<Personal> personalAuxList = new ArrayList<Personal>()
def campaigns = Campaign.findAllByEntidad(entidadInstance,[sort: "fechaFin", order: "desc"])
//Here a declare a DetachedCriteria using where method of domain class
def notificacionesQuery = Notificacion.where {
orden.linea.propuesta.campaign in campaigns
}
//For each persona from a search result done before
for(Personal person : result.results){
if(!personalAuxList.contains(person)){
//I add a condition to query creating new one
def notisOfPersonalQuery = notificacionesQuery.where {
personal == person
}
//Fail in this line when i list the result
def notificaciones = notisOfPersonalQuery.list()
notificaciones = notificaciones.sort{it.orden.linea.fin}.reverse()
notisOfPersonal.put(person.id, notificaciones.empty ? null : notificaciones.first())
personalAuxList.add(person)
}
}
That works fine on local, but when i upload the war, start failing in the server:
Class: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') and this_.personal_id=6616' at line 1
Trace:
Line | Method
->> 411 | handleNewInstance in com.mysql.jdbc.Util
| 386 | getInstance in ''
| 1052 | createSQLException . in com.mysql.jdbc.SQLError
| 4098 | checkErrorPacket in com.mysql.jdbc.MysqlIO
| 4030 | checkErrorPacket . . in ''
| 2490 | sendCommand in ''
| 2651 | sqlQueryDirect . . . in ''
| 2677 | execSQL in com.mysql.jdbc.ConnectionImpl
| 2134 | executeInternal . . in com.mysql.jdbc.PreparedStatement
| 2300 | executeQuery in ''
| 97 | executeQuery . . . . in org.apache.commons.dbcp.DelegatingPreparedStatement
| 671 | doCall in grails.gorm.DetachedCriteria$_list_closure2
| 934 | doCall . . . . . . . in grails.gorm.DetachedCriteria$_withPopulatedQuery_closure9
| 669 | doCall in org.grails.datastore.gorm.GormStaticApi$_withDatastoreSession_closure20
| 302 | execute . . . . . . in org.grails.datastore.mapping.core.DatastoreUtils
| 34 | execute in org.grails.datastore.gorm.AbstractDatastoreApi
| 668 | withDatastoreSession in org.grails.datastore.gorm.GormStaticApi
| 916 | withPopulatedQuery in grails.gorm.DetachedCriteria
| 667 | list . . . . . . . . in ''
| 666 | list in ''
| 301 | search . . . . . . . in com.publidirecta.PersonalController
^ 722 | run in java.lang.Thread
I solve it finally, on local i got campaigns in the DDBB but on real server no, so i change the code to add a condition if there's no campaigns:
ArrayList<Personal> personalAuxList = new ArrayList<Personal>()
def campaigns = Campaign.findAllByEntidad(entidadInstance,[sort: "fechaFin", order: "desc"])
if (campaigns != null && campaigns.size() > 0) {
def notificacionesQuery = Notificacion.where {
orden.linea.propuesta.campaign in campaigns
}
for(Personal person : result.results){
if(!personalAuxList.contains(person)){
def notisOfPersonalQuery = notificacionesQuery.where {
personal == person
}
def notificaciones = notisOfPersonalQuery.list()
notificaciones = notificaciones.sort{it.orden.linea.fin}.reverse()
notisOfPersonal.put(person.id, notificaciones.empty ? null : notificaciones.first())
personalAuxList.add(person)
}
}
}